function d(a){
    throw a;
}
var i=true,j=null,k=false,aa=Infinity,l=Error,ba=undefined,ca=encodeURIComponent,da=parseInt,ea=parseFloat,m=String,p=window,fa=Number,ga=Object,q=document,ha=decodeURIComponent,ia=isNaN,ja=alert,ka=screen,la=RegExp,r=Math,ma=Array;
function na(a,b){
    return a.toString=b
}
function oa(a,b){
    return a.onreadystatechange=b
}
function pa(a,b){
    return a.length=b
}
function qa(a,b){
    return a.title=b
}
function ra(a,b){
    return a.position=b
}
function sa(a,b){
    return a.selectedIndex=b
}
function t(a,b){
    return a.className=b
}
function ta(a,b){
    return a.width=b
}
function ua(a,b){
    return a.text=b
}
function va(a,b){
    return a.checked=b
}
function wa(a,b){
    return a.load=b
}
function xa(a,b){
    return a.innerHTML=b
}
function ya(a,b){
    return a.selected=b
}
function za(a,b){
    return a.value=b
}
function Aa(a,b){
    return a.disabled=b
}
function Ba(a,b){
    return a.dispatchEvent=b
}
function Ca(a,b){
    return a.currentTarget=b
}
function Da(a,b){
    return a.left=b
}
function Ea(a,b){
    return a.target=b
}
function Fa(a,b){
    return a.screenX=b
}
function Ga(a,b){
    return a.screenY=b
}
function Ha(a,b){
    return a.send=b
}
function Ia(a,b){
    return a.remove=b
}
function Ja(a,b){
    return a.coords=b
}
function Ka(a,b){
    return a.keyCode=b
}
function La(a,b){
    return a.handleEvent=b
}
function Ma(a,b){
    return a.removeNode=b
}
function Na(a,b){
    return a.action=b
}
function Oa(a,b){
    return a.type=b
}
function Pa(a,b){
    return a.contains=b
}
function Ra(a,b){
    return a.clear=b
}
function Sa(a,b){
    return a.border=b
}
function Ta(a,b){
    return a.reset=b
}
function Ua(a,b){
    return a.name=b
}
function Va(a,b){
    return a.overflow=b
}
function Wa(a,b){
    return a.display=b
}
function Xa(a,b){
    return a.height=b
}
function Ya(a,b){
    return a.clientX=b
}
function Za(a,b){
    return a.clientY=b
}
function $a(a,b){
    return a.visibility=b
}
var ab="setDate",u="setData",v="appendChild",bb="scrollTop",w="push",cb="stop",db="toString",eb="getMonth",fb="altKey",gb="activeElement",x="length",hb="propertyIsEnumerable",ib="title",jb="getBoundingClientRect",kb="open",y="prototype",lb="test",mb="shift",nb="relatedTarget",ob="className",pb="replaceChild",qb="clearTimeout",rb="exec",z="width",sb="text",tb="clientWidth",ub="round",vb="abort",wb="checked",xb="slice",yb="setTimeout",B="replace",zb="nodeType",Ab="document",Bb="data",Cb="getSeconds",
Db="ctrlKey",Eb="load",Fb="split",Gb="floor",Hb="content",Ib="getElementById",Jb="offsetWidth",Kb="concat",Lb="charAt",Mb="blur",Nb="createTextNode",Ob="stopPropagation",Pb="stack",C="getData",Qb="getDate",D="value",Rb="location",Sb="preventDefault",Tb="item",Ub="insertBefore",Vb="button",E="indexOf",Wb="metaKey",Xb="disabled",Yb="message",Zb="hasOwnProperty",$b="getComputedStyle",F="dispatchEvent",H="style",ac="close",bc="nodeName",cc="currentTarget",dc="body",ec="left",fc="ownerDocument",gc="view",
hc="removeChild",ic="parent",I="target",jc="screenX",kc="screenY",lc="lastChild",J="call",mc="media",nc="match",oc="getBoxObjectFor",pc="send",qc="isOpen",sc="readyState",tc="options",uc="charCode",vc="opera",wc="remove",xc="start",yc="lastIndexOf",zc="focus",Ac="getAttribute",K="createElement",Bc="coords",Cc="scrollHeight",Dc="keyCode",Ec="firstChild",Fc="getFullYear",Gc="forEach",Hc="clientHeight",Ic="scrollLeft",Jc="charCodeAt",Kc="clientLeft",Lc="addEventListener",Mc="sort",Nc="bottom",Oc="fireEvent",
Pc="setAttribute",Qc="currentStyle",Rc="href",Sc="substring",Tc="clientTop",M="handleEvent",Uc="removeNode",Vc="console",Wc="rows",Xc="detach",Yc="action",Zc="type",$c="apply",ad="clear",bd="childNodes",cd="shiftKey",dd="tagName",ed="reset",fd="defaultView",gd="bind",hd="attributes",N="name",O="parentNode",id="getHours",jd="getMinutes",kd="fileName",ld="display",md="nextSibling",nd="offsetTop",pd="contentWindow",P="height",qd="toUpperCase",rd="splice",sd="getTime",td="offsetHeight",ud="join",vd="unshift",
wd="setActive",xd="getElementsByTagName",yd="nodeValue",zd="toLowerCase",Ad="frames",Bd="clientX",Cd="clientY",Dd="documentElement",Ed="substr",Fd="right",Q,Gd=Gd||{
}
,S=this,Hd=function(a,b,c){
    a=a[Fb](".");
    c=c||S;
    !(a[0]in c)&&c.execScript&&c.execScript("var "+a[0]);
    for(var e;
    a[x]&&(e=a[mb]());
    )if(!a[x]&&b!==ba)c[e]=b;
    else c=c[e]?c[e]:c[e]={
    }
}
,Id=function(a,b){
    for(var c=a[Fb]("."),e=b||S,f;
    f=c[mb]();
    )if(e[f]!=j)e=e[f];
    else return j;
    return e
}
,Jd=function(){
}
,Kd=function(a){
    a.getInstance=function(){
        return a.instance_||
        (a.instance_=new a)
    }
}
,Ld=function(a){
    var b=typeof a;
    if(b=="object")if(a){
        if(a instanceof ma||!(a instanceof ga)&&ga[y][db][J](a)=="[object Array]"||typeof a[x]=="number"&&typeof a[rd]!="undefined"&&typeof a[hb]!="undefined"&&!a[hb]("splice"))return"array";
        if(!(a instanceof ga)&&(ga[y][db][J](a)=="[object Function]"||typeof a[J]!="undefined"&&typeof a[hb]!="undefined"&&!a[hb]("call")))return"function"
    }
    else return"null";
    else if(b=="function"&&typeof a[J]=="undefined")return"object";
    return b
}
,Md=function(a){
    return Ld(a)==
    "array"
}
,Nd=function(a){
    var b=Ld(a);
    return b=="array"||b=="object"&&typeof a[x]=="number"
}
,Od=function(a){
    return typeof a=="string"
}
,Pd=function(a){
    return typeof a=="number"
}
,Qd=function(a){
    return Ld(a)=="function"
}
,Rd=function(a){
    a=Ld(a);
    return a=="object"||a=="array"||a=="function"
}
,Ud=function(a){
    return a[Sd]||(a[Sd]=++Td)
}
,Sd="closure_uid_"+r[Gb](r.random()*2147483648)[db](36),Td=0,Vd=function(a){
    var b=Ld(a);
    if(b=="object"||b=="array"){
        if(a.clone)return a.clone();
        b=b=="array"?[]:{
        }
        ;
        for(var c in a)b[c]=
        Vd(a[c]);
        return b
    }
    return a
}
,Wd=function(a){
    return a[J][$c](a[gd],arguments)
}
,Xd=function(a,b){
    var c=b||S;
    if(arguments[x]>2){
        var e=ma[y][xb][J](arguments,2);
        return function(){
            var f=ma[y][xb][J](arguments);
            ma[y][vd][$c](f,e);
            return a[$c](c,f)
        }
    }
    else return function(){
        return a[$c](c,arguments)
    }
}
,T=function(){
    T=Function[y][gd]&&Function[y][gd][db]()[E]("native code")!=-1?Wd:Xd;
    return T[$c](j,arguments)
}
,Zd=function(a){
    var b=ma[y][xb][J](arguments,1);
    return function(){
        var c=ma[y][xb][J](arguments);
        c[vd][$c](c,
        b);
        return a[$c](this,c)
    }
}
,$d=Date.now||function(){
    return+new Date
}
,U=function(a,b){
    function c(){
    }
    c.prototype=b[y];
    a.superClass_=b[y];
    a.prototype=new c;
    a[y].constructor=a
};
Function[y].bind=Function[y][gd]||function(a){
    if(arguments[x]>1){
        var b=ma[y][xb][J](arguments,1);
        b[vd](this,a);
        return T[$c](j,b)
    }
    else return T(this,a)
};
var ae=function(a){
    this.stack=l()[Pb]||"";
    if(a)this.message=m(a)
};
U(ae,l);
Ua(ae[y],"CustomError");
var be=function(a,b){
    return a[yc](b,0)==0
}
,ce=function(a,b){
    var c=a[x]-b[x];
    return c>=0&&a[E](b,c)==c
}
,de=function(a){
    for(var b=1;
    b<arguments[x];
    b++){
        var c=m(arguments[b])[B](/\$/g,"$$$$");
        a=a[B](/\%s/,c)
    }
    return a
}
,ee=function(a){
    return/^[\s\xa0]*$/[lb](a)
}
,ge=function(a){
    return ee(fe(a))
}
,he=function(a){
    return!/[^a-zA-Z0-9]/[lb](a)
}
,ie=function(a){
    return a[B](/(\r\n|\r|\n)/g,"\n")
}
,je=function(a){
    return a[B](/^[\s\xa0]+|[\s\xa0]+$/g,"")
}
,ke=/^[a-zA-Z0-9\-_.!~*'()]*$/,le=function(a){
a=m(a);
if(!ke[lb](a))return ca(a);
return a
}
,me=function(a,b){
return a[B](/(\r\n|\r|\n)/g,b?"<br />":"<br>")
}
,se=function(a,b){
if(b)return a[B](ne,"&amp;
")[B](oe,"&lt;
")[B](pe,"&gt;
")[B](qe,"&quot;
");
else{
if(!re[lb](a))return a;
if(a[E]("&")!=-1)a=a[B](ne,"&amp;
");
if(a[E]("<")!=-1)a=a[B](oe,"&lt;
");
if(a[E](">")!=-1)a=a[B](pe,"&gt;
");
if(a[E]('"')!=-1)a=a[B](qe,"&quot;
");
return a
}
}
,ne=/&/g,oe=/</g,pe=/>/g,qe=/\"/g,re=/[&<>\"]/,te=function(a){
return a[B](/&([^;
]+);
/g,function(b,c){
switch(c){
case "amp":return"&";
case "lt":return"<";
case "gt":return">";
case "quot":return'"';
default:if(c[Lb](0)=="#"){
var e=fa("0"+c[Ed](1));
if(!ia(e))return m.fromCharCode(e)
}
return b
}
}
)
}
,ue=function(a,b){
return me(a[B](/  /g," &#160;
"),b)
}
,we=function(a,b,c){
if(c){
a=a;
if(ve(a,"&")){
if("document"in S&&!ve(a,"<")){
a=a;
var e=S[Ab][K]("div");
xa(e,"<pre>x"+a+"</pre>");
e[Ec].normalize&&e[Ec].normalize();
a=e[Ec][Ec][yd][xb](1);
xa(e,"");
a=ie(a)
}
else a=te(a);
a=a
}
else a=a;
a=a
}
if(a[x]>b)a=a[Sc](0,b-3)+"...";
if(c)a=se(a);
return a
}
,xe={
"\u0000":"\\0","\u0008":"\\b","\u000c":"\\f",
"\n":"\\n","\r":"\\r","\t":"\\t","\u000b":"\\x0B",'"':'\\"',"\\":"\\\\"
}
,ye={
"'":"\\'"
}
,ve=function(a,b){
return a[E](b)!=-1
}
,ze=function(a){
return m(a)[B](/([-()\[\]{
}
+?*.$\^|,:#<!\\])/g,"\\$1")[B](/\x08/g,"\\x08")
}
,Ae=function(a,b,c){
a=c!==ba?a.toFixed(c):m(a);
c=a[E](".");
if(c==-1)c=a[x];
return ma(r.max(0,b-c)+1)[ud]("0")+a
}
,fe=function(a){
return a==j?"":m(a)
}
,Be=function(){
return r[Gb](r.random()*2147483648)[db](36)+(r[Gb](r.random()*2147483648)^$d())[db](36)
}
,De=function(a,b){
for(var c=0,e=je(m(a))[Fb]("."),
f=je(m(b))[Fb]("."),g=r.max(e[x],f[x]),h=0;
c==0&&h<g;
h++){
var n=e[h]||"",o=f[h]||"",s=la("(\\d*)(\\D*)","g"),A=la("(\\d*)(\\D*)","g");
do{
var G=s[rb](n)||["","",""],R=A[rb](o)||["","",""];
if(G[0][x]==0&&R[0][x]==0)break;
c=G[1][x]==0?0:da(G[1],10);
var L=R[1][x]==0?0:da(R[1],10);
c=Ce(c,L)||Ce(G[2][x]==0,R[2][x]==0)||Ce(G[2],R[2])
}
while(c==0)
}
return c
}
,Ce=function(a,b){
if(a<b)return-1;
else if(a>b)return 1;
return 0
}
,Ee=function(a){
var b=fa(a);
if(b==0&&ee(a))return NaN;
return b
};
var Fe=function(a,b){
b[vd](a);
ae[J](this,de[$c](j,b));
b[mb]();
this.messagePattern=a
};
U(Fe,ae);
Ua(Fe[y],"AssertionError");
var He=function(a,b){
if(!a){
var c=ma[y][xb][J](arguments,2),e="Assertion failed";
if(b){
e+=": "+b;
var f=c
}
d(new Fe(""+e,f||[]))
}
return a
}
,Ie=function(a){
d(new Fe("Failure"+(a?": "+a:""),ma[y][xb][J](arguments,1)))
};
var Je=ma[y],Ke=Je[E]?function(a,b,c){
He(a[x]!=j);
return Je[E][J](a,b,c)
}
:function(a,b,c){
c=c==j?0:c<0?r.max(0,a[x]+c):c;
if(Od(a)){
if(!Od(b)||b[x]!=1)return-1;
return a[E](b,c)
}
for(c=c;
c<a[x];
c++)if(c in a&&a[c]===b)return c;
return-1
}
,Le=Je[Gc]?function(a,b,c){
He(a[x]!=j);
Je[Gc][J](a,b,c)
}
:function(a,b,c){
for(var e=a[x],f=Od(a)?a[Fb](""):a,g=0;
g<e;
g++)g in f&&b[J](c,f[g],g,a)
}
,Me=Je.filter?function(a,b,c){
He(a[x]!=j);
return Je.filter[J](a,b,c)
}
:function(a,b,c){
for(var e=a[x],f=[],g=0,h=Od(a)?a[Fb](""):
a,n=0;
n<e;
n++)if(n in h){
var o=h[n];
if(b[J](c,o,n,a))f[g++]=o
}
return f
}
,Ne=Je.map?function(a,b,c){
He(a[x]!=j);
return Je.map[J](a,b,c)
}
:function(a,b,c){
for(var e=a[x],f=ma(e),g=Od(a)?a[Fb](""):a,h=0;
h<e;
h++)if(h in g)f[h]=b[J](c,g[h],h,a);
return f
}
,Oe=Je.every?function(a,b,c){
He(a[x]!=j);
return Je.every[J](a,b,c)
}
:function(a,b,c){
for(var e=a[x],f=Od(a)?a[Fb](""):a,g=0;
g<e;
g++)if(g in f&&!b[J](c,f[g],g,a))return k;
return i
}
,Pe=function(a,b,c){
for(var e=a[x],f=Od(a)?a[Fb](""):a,g=0;
g<e;
g++)if(g in f&&
b[J](c,f[g],g,a))return g;
return-1
}
,Qe=function(a,b){
return Ke(a,b)>=0
}
,Se=function(a,b){
var c=Ke(a,b),e;
if(e=c>=0)Re(a,c);
return e
}
,Re=function(a,b){
He(a[x]!=j);
return Je[rd][J](a,b,1)[x]==1
}
,Te=function(){
return Je[Kb][$c](Je,arguments)
}
,Ue=function(a){
if(Md(a))return Te(a);
else{
for(var b=[],c=0,e=a[x];
c<e;
c++)b[c]=a[c];
return b
}
}
,Ve=function(a){
for(var b=1;
b<arguments[x];
b++){
var c=arguments[b],e;
if(Md(c)||(e=Nd(c))&&c[Zb]("callee"))a[w][$c](a,c);
else if(e)for(var f=a[x],g=c[x],h=0;
h<g;
h++)a[f+
h]=c[h];
else a[w](c)
}
}
,Xe=function(a){
He(a[x]!=j);
return Je[rd][$c](a,We(arguments,1))
}
,We=function(a,b,c){
He(a[x]!=j);
return arguments[x]<=2?Je[xb][J](a,b):Je[xb][J](a,b,c)
}
,Ze=function(a,b){
He(a[x]!=j);
Je[Mc][J](a,b||Ye)
}
,Ye=function(a,b){
return a>b?1:a<b?-1:0
};
var $e="StopIteration"in S?S.StopIteration:l("StopIteration"),af=function(){
};
af[y].next=function(){
d($e)
};
af[y].__iterator__=function(){
return this
};
var bf=function(a){
if(a instanceof af)return a;
if(typeof a.__iterator__=="function")return a.__iterator__(k);
if(Nd(a)){
var b=0,c=new af;
c.next=function(){
for(;
;
){
if(b>=a[x])d($e);
if(b in a)return a[b++];
else b++
}
};
return c
}
d(l("Not implemented"))
}
,cf=function(a,b,c){
if(Nd(a))try{
Le(a,b,c)
}
catch(e){
if(e!==$e)d(e)
}
else{
a=bf(a);
try{
for(;
;
)b[J](c,a.next(),ba,a)
}
catch(f){
if(f!==$e)d(f)
}
}
};
var df=function(a,b,c){
for(var e in a)b[J](c,a[e],e,a)
}
,ef=function(a){
var b=[],c=0,e;
for(e in a)b[c++]=a[e];
return b
}
,ff=function(a){
var b=[],c=0,e;
for(e in a)b[c++]=e;
return b
}
,gf=function(a){
for(var b in a)return k;
return i
}
,hf=function(a,b){
var c;
if(c=b in a)delete a[b];
return c
}
,jf=function(a,b,c){
if(b in a)d(l('The object already contains the key "'+b+'"'));
a[b]=c
}
,kf=function(a,b,c){
if(b in a)return a[b];
return c
}
,lf=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString",
"toString","valueOf"],mf=function(a){
for(var b,c,e=1;
e<arguments[x];
e++){
c=arguments[e];
for(b in c)a[b]=c[b];
for(var f=0;
f<lf[x];
f++){
b=lf[f];
if(ga[y][Zb][J](c,b))a[b]=c[b]
}
}
}
,nf=function(){
var a=arguments[x];
if(a==1&&Md(arguments[0]))return nf[$c](j,arguments[0]);
if(a%2)d(l("Uneven number of arguments"));
for(var b={
}
,c=0;
c<a;
c+=2)b[arguments[c]]=arguments[c+1];
return b
};
var of=function(a){
if(typeof a.getValues=="function")return a.getValues();
if(Od(a))return a[Fb]("");
if(Nd(a)){
for(var b=[],c=a[x],e=0;
e<c;
e++)b[w](a[e]);
return b
}
return ef(a)
}
,pf=function(a,b,c){
if(typeof a[Gc]=="function")a[Gc](b,c);
else if(Nd(a)||Od(a))Le(a,b,c);
else{
var e;
var f=a;
if(typeof f.getKeys=="function")e=f.getKeys();
else if(typeof f.getValues!="function")if(Nd(f)||Od(f)){
e=[];
f=f[x];
for(var g=0;
g<f;
g++)e[w](g);
e=e
}
else e=ff(f);
else e=void 0;
f=of(a);
g=f[x];
for(var h=0;
h<g;
h++)b[J](c,f[h],
e&&e[h],a)
}
};
var qf=function(a){
this.map_={
};
this.keys_=[];
var b=arguments[x];
if(b>1){
if(b%2)d(l("Uneven number of arguments"));
for(var c=0;
c<b;
c+=2)this.set(arguments[c],arguments[c+1])
}
else a&&this.addAll(a)
};
Q=qf[y];
Q.count_=0;
Q.version_=0;
Q.getCount=function(){
return this.count_
};
Q.getValues=function(){
this.cleanupKeysArray_();
for(var a=[],b=0;
b<this.keys_[x];
b++){
var c=this.keys_[b];
a[w](this.map_[c])
}
return a
};
Q.getKeys=function(){
this.cleanupKeysArray_();
return this.keys_[Kb]()
};
Q.containsKey=function(a){
return rf(this.map_,a)
};
Q.isEmpty=function(){
return this.count_==0
};
Ra(Q,function(){
this.map_={
};
pa(this.keys_,0);
this.version_=this.count_=0
}
);
Ia(Q,function(a){
if(rf(this.map_,a)){
delete this.map_[a];
this.count_--;
this.version_++;
this.keys_[x]>2*this.count_&&this.cleanupKeysArray_();
return i
}
return k
}
);
Q.cleanupKeysArray_=function(){
if(this.count_!=this.keys_[x]){
for(var a=0,b=0;
a<this.keys_[x];
){
var c=this.keys_[a];
if(rf(this.map_,c))this.keys_[b++]=c;
a++
}
pa(this.keys_,b)
}
if(this.count_!=this.keys_[x]){
var e={
};
for(b=a=0;
a<this.keys_[x];
){
c=this.keys_[a];
if(!rf(e,c)){
this.keys_[b++]=c;
e[c]=1
}
a++
}
pa(this.keys_,b)
}
};
Q.get=function(a,b){
if(rf(this.map_,a))return this.map_[a];
return b
};
Q.set=function(a,b){
if(!rf(this.map_,a)){
this.count_++;
this.keys_[w](a);
this.version_++
}
this.map_[a]=b
};
Q.addAll=function(a){
var b;
if(a instanceof qf){
b=a.getKeys();
a=a.getValues()
}
else{
b=ff(a);
a=ef(a)
}
for(var c=0;
c<b[x];
c++)this.set(b[c],a[c])
};
Q.clone=function(){
return new qf(this)
};
Q.__iterator__=function(a){
this.cleanupKeysArray_();
var b=0,c=this.keys_,e=this.map_,f=this.version_,g=this,h=new af;
h.next=function(){
for(;
;
){
if(f!=g.version_)d(l("The map has changed since the iterator was created"));
if(b>=c[x])d($e);
var n=c[b++];
return a?n:e[n]
}
};
return h
};
var rf=function(a,b){
return ga[y][Zb][J](a,b)
};
var sf=function(a){
this.map_=new qf;
a&&this.addAll(a)
}
,tf=function(a){
var b=typeof a;
return b=="object"&&a||b=="function"?"o"+Ud(a):b[Ed](0,1)+a
};
Q=sf[y];
Q.getCount=function(){
return this.map_.getCount()
};
Q.add=function(a){
this.map_.set(tf(a),a)
};
Q.addAll=function(a){
a=of(a);
for(var b=a[x],c=0;
c<b;
c++)this.add(a[c])
};
Q.removeAll=function(a){
a=of(a);
for(var b=a[x],c=0;
c<b;
c++)this[wc](a[c])
};
Ia(Q,function(a){
return this.map_[wc](tf(a))
}
);
Ra(Q,function(){
this.map_[ad]()
}
);
Q.isEmpty=function(){
return this.map_.isEmpty()
};
Pa(Q,function(a){
return this.map_.containsKey(tf(a))
}
);
Q.intersection=function(a){
var b=new sf;
a=of(a);
for(var c=0;
c<a[x];
c++){
var e=a[c];
this.contains(e)&&b.add(e)
}
return b
};
Q.getValues=function(){
return this.map_.getValues()
};
Q.clone=function(){
return new sf(this)
};
Q.__iterator__=function(){
return this.map_.__iterator__(k)
};
var vf=function(a,b){
try{
var c,e=a,f=Id("window.location.href");
c=typeof e=="string"?{
message:e,name:"Unknown error",lineNumber:"Not available",fileName:f,stack:"Not available"
}
:!e.lineNumber||!e[kd]||!e[Pb]?{
message:e[Yb],name:e[N],lineNumber:e.lineNumber||e.line||"Not available",fileName:e[kd]||e.filename||e.sourceURL||f,stack:e[Pb]||"Not available"
}
:e;
var g="Message: "+se(c[Yb])+'\nUrl: <a href="view-source:'+c[kd]+'" target="_new">'+c[kd]+"</a>\nLine: "+c.lineNumber+"\n\nBrowser stack:\n"+se(c[Pb]+
"-> ")+"[end]\n\nJS stack traversal:\n"+se(uf(b)+"-> ");
return g
}
catch(h){
return"Exception trying to expose exception! You win, we lose. "+h
}
}
,uf=function(a){
return wf(a||arguments.callee.caller,[])
}
,wf=function(a,b){
var c=[];
if(Qe(b,a))c[w]("[...circular reference...]");
else if(a&&b[x]<50){
c[w](xf(a)+"(");
for(var e=a.arguments,f=0;
f<e[x];
f++){
f>0&&c[w](", ");
var g;
g=e[f];
switch(typeof g){
case "object":g=g?"object":"null";
break;
case "string":g=g;
break;
case "number":g=m(g);
break;
case "boolean":g=g?
"true":"false";
break;
case "function":g=(g=xf(g))?g:"[fn]";
break;
default:g=typeof g
}
if(g[x]>40)g=g[Ed](0,40)+"...";
c[w](g)
}
b[w](a);
c[w](")\n");
try{
c[w](wf(a.caller,b))
}
catch(h){
c[w]("[exception trying to get caller]\n")
}
}
else a?c[w]("[...long stack...]"):c[w]("[end]");
return c[ud]("")
}
,xf=function(a){
a=m(a);
if(!yf[a]){
var b=/function ([^\(]+)/[rb](a);
if(b){
b=b[1];
yf[a]=b
}
else yf[a]="[Anonymous]"
}
return yf[a]
}
,yf={
};
var zf=function(a,b,c,e,f){
this[ed](a,b,c,e,f)
};
zf[y].sequenceNumber_=0;
zf[y].exception_=j;
zf[y].exceptionText_=j;
var Af=0;
Q=zf[y];
Ta(Q,function(a,b,c,e,f){
this.sequenceNumber_=typeof f=="number"?f:Af++;
this.time_=e||$d();
this.level_=a;
this.msg_=b;
this.loggerName_=c;
delete this.exception_;
delete this.exceptionText_
}
);
Q.getLoggerName=function(){
return this.loggerName_
};
Q.getException=function(){
return this.exception_
};
Q.setException=function(a){
this.exception_=a
};
Q.getExceptionText=function(){
return this.exceptionText_
};
Q.setExceptionText=function(a){
this.exceptionText_=a
};
Q.getLevel=function(){
return this.level_
};
Q.setLevel=function(a){
this.level_=a
};
Q.getMessage=function(){
return this.msg_
};
Q.getMillis=function(){
return this.time_
};
var Bf=function(a){
this.name_=a
};
Bf[y].parent_=j;
Bf[y].level_=j;
Bf[y].children_=j;
Bf[y].handlers_=j;
var Cf=function(a,b){
Ua(this,a);
za(this,b)
};
na(Cf[y],function(){
return this[N]
}
);
var Df=new Cf("SHOUT",1200),Ef=new Cf("SEVERE",1E3),Ff=new Cf("WARNING",900),Gf=new Cf("INFO",800),Hf=new Cf("CONFIG",700),If=new Cf("FINE",500),Jf=new Cf("FINER",400),Kf=new Cf("FINEST",300);
Q=Bf[y];
Q.getName=function(){
return this.name_
};
Q.addHandler=function(a){
if(!this.handlers_)this.handlers_=[];
this.handlers_[w](a)
};
Q.removeHandler=function(a){
var b=this.handlers_;
return!!b&&Se(b,a)
};
Q.getParent=function(){
return this.parent_
};
Q.getChildren=function(){
if(!this.children_)this.children_={
};
return this.children_
};
Q.setLevel=function(a){
this.level_=a
};
Q.getLevel=function(){
return this.level_
};
Q.getEffectiveLevel=function(){
if(this.level_)return this.level_;
if(this.parent_)return this.parent_.getEffectiveLevel();
Ie("Root logger has no level set.");
return j
};
Q.isLoggable=function(a){
return a[D]>=this.getEffectiveLevel()[D]
};
Q.log=function(a,b,c){
this.isLoggable(a)&&this.doLogRecord_(this.getLogRecord(a,b,c))
};
Q.getLogRecord=function(a,b,c){
var e;
e=e=new zf(a,m(b),this.name_);
if(c){
e.setException(c);
e.setExceptionText(vf(c,arguments.callee.caller))
}
return e
};
Q.severe=function(a,b){
this.log(Ef,a,b)
};
Q.warning=function(a,b){
this.log(Ff,a,b)
};
Q.info=function(a,b){
this.log(Gf,a,b)
};
Q.fine=function(a,b){
this.log(If,a,b)
};
Q.finer=function(a,b){
this.log(Jf,a,b)
};
Q.finest=function(a,b){
this.log(Kf,a,b)
};
Q.logToSpeedTracer_=function(a){
S[Vc]&&S[Vc].markTimeline&&S[Vc].markTimeline(a)
};
Q.doLogRecord_=function(a){
this.logToSpeedTracer_("log:"+a.getMessage());
for(var b=this;
b;
){
b.callPublish_(a);
b=b.getParent()
}
};
Q.callPublish_=function(a){
if(this.handlers_)for(var b=0,c;
c=this.handlers_[b];
b++)c(a)
};
Q.setParent_=function(a){
this.parent_=a
};
Q.addChild_=function(a,b){
this.getChildren()[a]=b
};
var Lf={
}
,Mf=j,Nf=function(){
if(!Mf){
Mf=new Bf("");
Lf[""]=Mf;
Mf.setLevel(Hf)
}
}
,Of=function(a){
Nf();
var b=Lf[a];
if(!(b=b)){
a=a;
b=new Bf(a);
var c=a[yc]("."),e=a[Ed](0,c);
c=a[Ed](c+1);
e=Of(e);
e.addChild_(c,b);
b.setParent_(e);
b=Lf[a]=b
}
return b
};
var Pf=function(){
};
Q=Pf[y];
Q.get=Jd;
Q.set=Jd;
Q.getChildNodes=Jd;
Q.getChildNode=Jd;
Q.getChildNodeValue=Jd;
Q.setChildNode=Jd;
Q.getDataName=Jd;
Q.setDataName=Jd;
Q.getDataPath=Jd;
wa(Q,Jd);
Q.isList=Jd;
var Qf=function(){
};
Q=Qf[y];
Q.set=Jd;
Q.getChildNodes=function(){
return new Rf
};
Q.getChildNode=function(){
return j
};
Q.getChildNodeValue=function(){
return j
};
Q.getDataName=Jd;
Q.getDataPath=function(){
var a="",b=this.getDataName();
if(this.getParent_&&this.getParent_())a=this.getParent_().getDataPath()+(b[E]("[")!=-1?"":"/");
return a+b
};
wa(Q,Jd);
Q.getParent_=j;
var Sf=function(a){
this.map_={
};
this.list_=[];
this.indexMap_={
};
if(a)for(var b=0,c;
c=a[b];
b++)this.add(c)
};
Q=Sf[y];
Q.add=function(a){
this.list_[w](a);
var b=a.getDataName();
if(b){
this.map_[b]=a;
this.indexMap_[b]=this.list_[x]-1
}
};
Q.get=function(a){
return this.map_[a]||j
};
Q.getByIndex=function(a){
return this.list_[a]||j
};
Q.getCount=function(){
return this.list_[x]
};
Q.setNode=function(a,b){
if(b==j)this[Uc](a);
else{
var c=this.indexMap_[a];
if(c!=j){
this.map_[a]=b;
this.list_[c]=b
}
else this.add(b)
}
};
Ma(Q,function(a){
var b=this.indexMap_[a];
if(b!=j){
this.list_[rd](b,1);
delete this.map_[a];
delete this.indexMap_[a];
for(var c in this.indexMap_)this.indexMap_[c]>b&&this.indexMap_[c]--
}
return b!=j
}
);
Q.indexOf=function(a){
return this.indexMap_[a]
};
var Rf=function(){
Sf[J](this)
};
U(Rf,Sf);
Rf[y].add=function(){
d(l("Can't add to EmptyNodeList"))
};
var Tf=function(a,b){
this.compareFn_=a;
Sf[J](this,b)
};
U(Tf,Sf);
Tf[y].add=function(a){
if(this.compareFn_){
var b;
b=this.list_;
for(var c=this.compareFn_||Ye,e=a,f=0,g=b[x],h;
f<g;
){
var n=f+g>>1,o;
o=c(e,b[n]);
if(o>0)f=n+1;
else{
g=n;
h=!o
}
}
b=h?f:~f;
if(b<0)b=-(b+1);
for(var s in this.indexMap_)this.indexMap_[s]>=b&&this.indexMap_[s]++;
Xe(this.list_,b,0,a);
if(s=a.getDataName()){
this.map_[s]=a;
this.indexMap_[s]=b
}
}
else this.append(a)
};
Tf[y].append=function(a){
Tf.superClass_.add[J](this,a)
};
Tf[y].setNode=function(a,b){
if(b==j)this[Uc](a);
else{
var c=this.indexMap_[a];
if(c!=j){
if(this.compareFn_){
var e=this.compareFn_(this.list_[c],b);
if(e==0){
this.map_[a]=b;
this.list_[c]=b
}
else{
this[Uc](a);
this.add(b)
}
}
}
else this.add(b)
}
};
var Uf=Of("goog.ds"),Vf=function(a,b){
var c=function(){
};
c.prototype=a;
c=new c;
c.getDataName=function(){
return b
};
return c
};
var Wf=function(a){
a&&this.setSource_(a)
};
Q=Wf[y];
Q.setSource_=function(a,b,c,e){
this.src_=a;
if(!c&&!e){
if(ce(a,"?")){
this.canBeEmpty_=i;
a=a[Sc](0,a[x]-1)
}
if(ce(a,"()"))if(ce(a,"name()")||ce(a,"count()")||ce(a,"position()")){
c=a[yc]("/");
if(c!=-1){
this.exprFn_=a[Sc](c+1);
a=a[Sc](0,c)
}
else{
this.exprFn_=a;
a="."
}
if(this.exprFn_=="count()")this.isCount_=i
}
}
this.parts_=b||a[Fb]("/");
this.size_=this.parts_[x];
this.last_=this.parts_[this.size_-1];
this.root_=this.parts_[0];
if(this.size_==1){
this.rootExpr_=this;
this.isAbsolute_=be(a,"$")
}
else{
this.rootExpr_=
Xf(this.root_,j,this,j);
this.isAbsolute_=this.rootExpr_.isAbsolute_;
this.root_=this.rootExpr_.root_
}
if(this.size_==1&&!this.isAbsolute_){
this.isCurrent_=a=="."||a=="";
this.isJustAttribute_=be(a,"@");
this.isAllChildNodes_=a=="*|text()";
this.isAllAttributes_=a=="@*";
this.isAllElements_=a=="*"
}
};
Q.getSource=function(){
return this.src_
};
Q.getLast=function(){
return this.last_
};
Q.getParent=function(){
if(!this.parentExprSet_){
if(this.size_>1)this.parentExpr_=Xf(j,this.parts_[xb](0,this.parts_[x]-1),this,j);
this.parentExprSet_=i
}
return this.parentExpr_
};
Q.getNext=function(){
if(!this.nextExprSet_){
if(this.size_>1)this.nextExpr_=Xf(j,this.parts_[xb](1),j,this);
this.nextExprSet_=i
}
return this.nextExpr_
};
Q.getValue=function(a){
if(a==j)a=V();
else if(this.isAbsolute_)a=a.getDataRoot?a.getDataRoot():V();
if(this.isCount_){
a=this.getNodes(a);
return a.getCount()
}
if(this.size_==1)return a.getChildNodeValue(this.root_);
else if(this.size_==0)return a.get();
a=a.getChildNode(this.root_);
return a==j?j:this.getNext().getValue(a)
};
Q.getNodes=function(a,b){
return this.getNodes_(a,k,b)
};
Q.getNode=function(a,b){
return this.getNodes_(a,i,b)
};
Q.getNodes_=function(a,b,c){
if(a==j)a=V();
else if(this.isAbsolute_)a=a.getDataRoot?a.getDataRoot():V();
if(this.size_==0&&b)return a;
else if(this.size_==0&&!b)return new Sf([a]);
else if(this.size_==1)if(b)return a.getChildNode(this.root_,c);
else return(b=a.getChildNode(this.root_))&&b.isList()?b.getChildNodes():a.getChildNodes(this.root_);
else{
a=a.getChildNode(this.root_,c);
if(a==j&&b)return j;
else if(a==j&&!b)return new Rf;
return this.getNext().getNodes_(a,b,c)
}
};
Q.canBeEmpty_=k;
Q.parts_=[];
Q.size_=j;
Q.last_=j;
Q.isCurrent_=k;
Q.isJustAttribute_=k;
Q.isAllChildNodes_=k;
Q.isAllAttributes_=k;
Q.isAllElements_=k;
Q.exprFn_=j;
Q.parentExpr_=j;
Q.nextExpr_=j;
var W=function(a){
var b=Yf[a];
if(b==j){
b=new Wf(a);
Yf[a]=b
}
return b
}
,Xf=function(a,b,c,e){
a=a||b[ud]("/");
var f=Yf[a];
if(f==j){
f=new Wf;
f.setSource_(a,b,c,e);
Yf[a]=f
}
return f
}
,Yf={
};
W(".");
W("*|text()");
W("*");
W("@*");
W("name()");
W("count()");
W("position()");
var Zf=function(){
this.dataSources_=new Sf;
this.autoloads_=new qf;
this.listenerMap_={
};
this.listenersByFunction_={
};
this.aliases_={
};
this.eventCount_=0;
this.indexedListenersByFunction_={
}
}
,$f=j;
U(Zf,Pf);
var V=function(){
$f||($f=new Zf);
return $f
};
Q=Zf[y];
Q.addDataSource=function(a,b,c){
b=!!b;
c=c||a.getDataName();
be(c,"$")||(c="$"+c);
a.setDataName(c);
this.dataSources_.add(a);
this.autoloads_.set(c,b)
};
Q.aliasDataSource=function(a,b){
if(!this.aliasListener_)this.aliasListener_=T(this.listenForAlias_,this);
if(this.aliases_[a]){
var c=this.aliases_[a].getSource();
this.removeListeners(this.aliasListener_,c+"/...",a)
}
this.aliases_[a]=W(b);
this.addListener(this.aliasListener_,b+"/...",a);
this.fireDataChange(a)
};
Q.listenForAlias_=function(a,b){
var c=this.aliases_[b];
if(c){
c=c.getSource();
a[E](c)==0?this.fireDataChange(b+a[Sc](c[x])):this.fireDataChange(b)
}
};
Q.getDataSource=function(a){
return this.aliases_[a]?this.aliases_[a].getNode():this.dataSources_.get(a)
};
Q.get=function(){
return this.dataSources_
};
Q.set=function(){
d(l("Can't set on DataManager"))
};
Q.getChildNodes=function(a){
return a?new Sf([this.getChildNode(a)]):this.dataSources_
};
Q.getChildNode=function(a){
return this.getDataSource(a)
};
Q.getChildNodeValue=function(a){
return(a=this.getDataSource(a))?a.get():j
};
Q.getDataName=function(){
return""
};
Q.getDataPath=function(){
return""
};
wa(Q,function(){
for(var a=this.dataSources_.getCount(),b=0;
b<a;
b++){
var c=this.dataSources_.getByIndex(b),e=this.autoloads_.get(c.getDataName());
e&&c[Eb]()
}
}
);
Q.isList=function(){
return k
};
Q.getEventCount=function(){
return this.eventCount_
};
Q.addListener=function(a,b,c){
var e=0;
if(ce(b,"/...")){
e=1E3;
b=b[Sc](0,b[x]-4)
}
else if(ce(b,"/*")){
e=1;
b=b[Sc](0,b[x]-2)
}
c=c||"";
var f=b+":"+c+":"+Ud(a);
c={
dataPath:b,id:c,fn:a
};
b=W(b);
a=Ud(a);
this.listenersByFunction_[a]||(this.listenersByFunction_[a]={
}
);
for(this.listenersByFunction_[a][f]={
listener:c,items:[]
};
b;
){
e={
listener:c,maxAncestors:e
};
var g=this.listenerMap_[b.getSource()];
if(g==j){
g={
};
this.listenerMap_[b.getSource()]=g
}
g[f]=e;
e=0;
b=b.getParent();
this.listenersByFunction_[a][f].items[w]({
key:f,
obj:g
}
)
}
};
Q.addIndexedListener=function(a,b,c){
var e=b[E]("*");
if(e==-1)this.addListener(a,b,c);
else{
e=b[Sc](0,e)+"...";
var f="$";
if(ce(b,"/...")){
b=b[Sc](0,b[x]-4);
f=""
}
var g=ze(b);
f=g[B](/\\\*/g,"([^\\/]+)")+f;
var h=la(f);
f=function(n){
var o=h[rb](n);
if(o){
o[mb]();
a(n,c,o)
}
};
this.addListener(f,e,c);
g=Ud(a);
this.indexedListenersByFunction_[g]||(this.indexedListenersByFunction_[g]={
}
);
b=b+":"+c;
this.indexedListenersByFunction_[g][b]={
listener:{
dataPath:e,fn:f,id:c
}
}
}
};
Q.removeListeners=function(a,b,c){
if(b&&ce(b,"/..."))b=b[Sc](0,b[x]-4);
else if(b&&ce(b,"/*"))b=b[Sc](0,b[x]-2);
this.removeListenersByFunction_(this.listenersByFunction_,k,a,b,c)
};
Q.removeListenersByFunction_=function(a,b,c,e,f){
c=Ud(c);
a=a[c];
if(a!=j)for(var g in a){
c=a[g];
var h=c.listener;
if((!e||e==h.dataPath)&&(!f||f==h.id)){
b&&this.removeListeners(h.fn,h.dataPath,h.id);
if(c.items)for(h=0;
h<c.items[x];
h++){
var n=c.items[h];
delete n.obj[n.key]
}
delete a[g]
}
}
};
Q.runWithoutFiringDataChanges=function(a){
if(this.disableFiring_)d(l("Can not nest calls to runWithoutFiringDataChanges"));
this.disableFiring_=i;
try{
a()
}
finally{
this.disableFiring_=k
}
};
Q.fireDataChange=function(a){
if(!this.disableFiring_){
for(var b=W(a),c=0;
b;
){
var e=this.listenerMap_[b.getSource()];
if(e)for(var f in e){
var g=e[f],h=g.listener;
c<=g.maxAncestors&&h.fn(a,h.id)
}
c++;
b=b.getParent()
}
this.eventCount_++
}
};
var ag,bg,cg,dg,eg,fg,gg,hg=function(){
return S.navigator?S.navigator.userAgent:j
}
,ig=function(){
return S.navigator
};
eg=dg=cg=bg=ag=k;
var jg;
if(jg=hg()){
var kg=ig();
ag=jg[E]("Opera")==0;
bg=!ag&&jg[E]("MSIE")!=-1;
dg=(cg=!ag&&jg[E]("WebKit")!=-1)&&jg[E]("Mobile")!=-1;
eg=!ag&&!cg&&kg.product=="Gecko"
}
var lg=ag,X=bg,mg=eg,ng=cg,og=dg,pg,qg=ig(),rg=pg=qg&&qg.platform||"";
fg=ve(rg,"Mac");
ve(rg,"Win");
ve(rg,"Linux");
gg=!!ig()&&ve(ig().appVersion||"","X11");
var sg=fg,tg=gg,ug;
a:{
var vg="",wg;
if(lg&&S[vc]){
var xg=S[vc].version;
vg=typeof xg=="function"?xg():xg
}
else{
if(mg)wg=/rv\:([^\);
]+)(\)|;
)/;
else if(X)wg=/MSIE\s+([^\);
]+)(\)|;
)/;
else if(ng)wg=/WebKit\/(\S+)/;
if(wg){
var yg=wg[rb](hg());
vg=yg?yg[1]:""
}
}
if(X){
var zg,Ag=S[Ab];
zg=Ag?Ag.documentMode:ba;
if(zg>ea(vg)){
ug=m(zg);
break a
}
}
ug=vg
}
var Bg=ug,Cg={
}
,Dg=function(a){
return Cg[a]||(Cg[a]=De(Bg,a)>=0)
};
var Eg,Fg=!X||Dg("9"),Gg=X&&!Dg("8");
var Hg=function(){
};
Hg[y].disposed_=k;
Hg[y].isDisposed=function(){
return this.disposed_
};
Hg[y].dispose=function(){
if(!this.disposed_){
this.disposed_=i;
this.disposeInternal()
}
};
Hg[y].disposeInternal=function(){
};
var Ig=function(a,b){
Oa(this,a);
Ea(this,b);
Ca(this,this[I])
};
U(Ig,Hg);
Q=Ig[y];
Q.disposeInternal=function(){
delete this[Zc];
delete this[I];
delete this[cc]
};
Q.propagationStopped_=k;
Q.returnValue_=i;
Q.stopPropagation=function(){
this.propagationStopped_=i
};
Q.preventDefault=function(){
this.returnValue_=k
};
var Jg=function(a){
a[Sb]()
};
var Kg=function(a,b){
a&&this.init(a,b)
};
U(Kg,Ig);
var Lg=[1,4,2];
Q=Kg[y];
Ea(Q,j);
Q.relatedTarget=j;
Q.offsetX=0;
Q.offsetY=0;
Ya(Q,0);
Za(Q,0);
Fa(Q,0);
Ga(Q,0);
Q.button=0;
Ka(Q,0);
Q.charCode=0;
Q.ctrlKey=k;
Q.altKey=k;
Q.shiftKey=k;
Q.metaKey=k;
Q.platformModifierKey=k;
Q.event_=j;
Q.init=function(a,b){
var c=Oa(this,a[Zc]);
Ea(this,a[I]||a.srcElement);
Ca(this,b);
var e=a[nb];
if(e){
if(mg)try{
e=e[bc]&&e
}
catch(f){
e=j
}
}
else if(c=="mouseover")e=a.fromElement;
else if(c=="mouseout")e=a.toElement;
this.relatedTarget=e;
this.offsetX=a.offsetX!==ba?a.offsetX:a.layerX;
this.offsetY=a.offsetY!==ba?a.offsetY:a.layerY;
Ya(this,a[Bd]!==ba?a[Bd]:a.pageX);
Za(this,a[Cd]!==ba?a[Cd]:a.pageY);
Fa(this,a[jc]||0);
Ga(this,a[kc]||0);
this.button=a[Vb];
Ka(this,a[Dc]||0);
this.charCode=a[uc]||(c=="keypress"?a[Dc]:
0);
this.ctrlKey=a[Db];
this.altKey=a[fb];
this.shiftKey=a[cd];
this.metaKey=a[Wb];
this.platformModifierKey=sg?a[Wb]:a[Db];
this.state=a.state;
this.event_=a;
delete this.returnValue_;
delete this.propagationStopped_
};
Q.isButton=function(a){
return Fg?this.event_[Vb]==a:this[Zc]=="click"?a==0:!!(this.event_[Vb]&Lg[a])
};
Q.stopPropagation=function(){
Kg.superClass_[Ob][J](this);
if(this.event_[Ob])this.event_[Ob]();
else this.event_.cancelBubble=i
};
Q.preventDefault=function(){
Kg.superClass_[Sb][J](this);
var a=this.event_;
if(a[Sb])a[Sb]();
else{
a.returnValue=k;
if(Gg)try{
if(a[Db]||a[Dc]>=112&&a[Dc]<=123)Ka(a,-1)
}
catch(b){
}
}
};
Q.getBrowserEvent=function(){
return this.event_
};
Q.disposeInternal=function(){
Kg.superClass_.disposeInternal[J](this);
this.event_=j;
Ea(this,j);
Ca(this,j);
this.relatedTarget=j
};
var Mg=function(a,b){
this.maxCount_=b;
this.freeQueue_=[];
this.createInitial_(a)
};
U(Mg,Hg);
Q=Mg[y];
Q.createObjectFn_=j;
Q.disposeObjectFn_=j;
Q.setCreateObjectFn=function(a){
this.createObjectFn_=a
};
Q.getObject=function(){
if(this.freeQueue_[x])return this.freeQueue_.pop();
return this.createObject()
};
Q.releaseObject=function(a){
this.freeQueue_[x]<this.maxCount_?this.freeQueue_[w](a):this.disposeObject(a)
};
Q.createInitial_=function(a){
if(a>this.maxCount_)d(l("[goog.structs.SimplePool] Initial cannot be greater than max"));
for(var b=0;
b<a;
b++)this.freeQueue_[w](this.createObject())
};
Q.createObject=function(){
return this.createObjectFn_?this.createObjectFn_():{
}
};
Q.disposeObject=function(a){
if(this.disposeObjectFn_)this.disposeObjectFn_(a);
else if(Rd(a))if(Qd(a.dispose))a.dispose();
else for(var b in a)delete a[b]
};
Q.disposeInternal=function(){
Mg.superClass_.disposeInternal[J](this);
for(var a=this.freeQueue_;
a[x];
)this.disposeObject(a.pop());
delete this.freeQueue_
};
var Ng,Og,Pg="ScriptEngine"in S;
Og=(Ng=Pg&&S.ScriptEngine()=="JScript")?S.ScriptEngineMajorVersion()+"."+S.ScriptEngineMinorVersion()+"."+S.ScriptEngineBuildVersion():"0";
var Qg=Ng,Rg=Og;
var Sg=function(){
}
,Tg=0;
Q=Sg[y];
Q.key=0;
Q.removed=k;
Q.callOnce=k;
Q.init=function(a,b,c,e,f,g){
if(Qd(a))this.isFunctionListener_=i;
else if(a&&a[M]&&Qd(a[M]))this.isFunctionListener_=k;
else d(l("Invalid listener argument"));
this.listener=a;
this.proxy=b;
this.src=c;
Oa(this,e);
this.capture=!!f;
this.handler=g;
this.callOnce=k;
this.key=++Tg;
this.removed=k
};
La(Q,function(a){
if(this.isFunctionListener_)return this.listener[J](this.handler||this.src,a);
return this.listener[M][J](this.listener,a)
}
);
var Ug,Vg,Wg,Xg,Yg,Zg,$g,ah,bh,ch,dh;
(function(){
function a(){
return{
count_:0,remaining_:0
}
}
function b(){
return[]
}
function c(){
var R=function(L){
return h[J](R.src,R.key,L)
};
return R
}
function e(){
return new Sg
}
function f(){
return new Kg
}
var g=Qg&&!(De(Rg,"5.7")>=0),h;
Zg=function(R){
h=R
};
if(g){
Ug=function(){
return n.getObject()
};
Vg=function(R){
n.releaseObject(R)
};
Wg=function(){
return o.getObject()
};
Xg=function(R){
o.releaseObject(R)
};
Yg=function(){
return s.getObject()
};
$g=function(){
s.releaseObject(c())
};
ah=function(){
return A.getObject()
};
bh=function(R){
A.releaseObject(R)
};
ch=function(){
return G.getObject()
};
dh=function(R){
G.releaseObject(R)
};
var n=new Mg(0,600);
n.setCreateObjectFn(a);
var o=new Mg(0,600);
o.setCreateObjectFn(b);
var s=new Mg(0,600);
s.setCreateObjectFn(c);
var A=new Mg(0,600);
A.setCreateObjectFn(e);
var G=new Mg(0,600);
G.setCreateObjectFn(f)
}
else{
Ug=a;
Vg=Jd;
Wg=b;
Xg=Jd;
Yg=c;
$g=Jd;
ah=e;
bh=Jd;
ch=f;
dh=Jd
}
}
)();
var eh={
}
,fh={
}
,gh={
}
,hh="on",ih={
}
,Y=function(a,b,c,e,f){
if(b)if(Md(b)){
for(var g=0;
g<b[x];
g++)Y(a,b[g],c,e,f);
return j
}
else{
e=!!e;
var h=fh;
b in h||(h[b]=Ug());
h=h[b];
if(!(e in h)){
h[e]=Ug();
h.count_++
}
h=h[e];
var n=Ud(a),o;
h.remaining_++;
if(h[n]){
o=h[n];
for(g=0;
g<o[x];
g++){
h=o[g];
if(h.listener==c&&h.handler==f){
if(h.removed)break;
return o[g].key
}
}
}
else{
o=h[n]=Wg();
h.count_++
}
g=Yg();
g.src=a;
h=ah();
h.init(c,g,a,b,e,f);
c=h.key;
g.key=c;
o[w](h);
eh[c]=h;
gh[n]||(gh[n]=Wg());
gh[n][w](h);
if(a[Lc]){
if(a==
S||!a.customEvent_)a[Lc](b,g,e)
}
else a.attachEvent(jh(b),g);
return c
}
else d(l("Invalid event type"))
}
,kh=function(a,b,c,e,f){
if(Md(b)){
for(var g=0;
g<b[x];
g++)kh(a,b[g],c,e,f);
return j
}
a=Y(a,b,c,e,f);
b=eh[a];
b.callOnce=i;
return a
}
,lh=function(a,b,c,e,f){
if(Md(b)){
for(var g=0;
g<b[x];
g++)lh(a,b[g],c,e,f);
return j
}
e=!!e;
a=mh(a,b,e);
if(!a)return k;
for(g=0;
g<a[x];
g++)if(a[g].listener==c&&a[g].capture==e&&a[g].handler==f)return nh(a[g].key);
return k
}
,nh=function(a){
if(!eh[a])return k;
var b=eh[a];
if(b.removed)return k;
var c=b.src,e=b[Zc],f=b.proxy,g=b.capture;
if(c.removeEventListener){
if(c==S||!c.customEvent_)c.removeEventListener(e,f,g)
}
else c.detachEvent&&c.detachEvent(jh(e),f);
c=Ud(c);
f=fh[e][g][c];
if(gh[c]){
var h=gh[c];
Se(h,b);
h[x]==0&&delete gh[c]
}
b.removed=i;
f.needsCleanup_=i;
oh(e,g,c,f);
delete eh[a];
return i
}
,oh=function(a,b,c,e){
if(!e.locked_)if(e.needsCleanup_){
for(var f=0,g=0;
f<e[x];
f++)if(e[f].removed){
var h=e[f].proxy;
h.src=j;
$g(h);
bh(e[f])
}
else{
if(f!=g)e[g]=e[f];
g++
}
pa(e,g);
e.needsCleanup_=k;
if(g==
0){
Xg(e);
delete fh[a][b][c];
fh[a][b].count_--;
if(fh[a][b].count_==0){
Vg(fh[a][b]);
delete fh[a][b];
fh[a].count_--
}
if(fh[a].count_==0){
Vg(fh[a]);
delete fh[a]
}
}
}
}
,ph=function(a,b,c){
var e=0,f=a==j,g=b==j,h=c==j;
c=!!c;
if(f)df(gh,function(o){
for(var s=o[x]-1;
s>=0;
s--){
var A=o[s];
if((g||b==A[Zc])&&(h||c==A.capture)){
nh(A.key);
e++
}
}
}
);
else{
a=Ud(a);
if(gh[a]){
a=gh[a];
for(f=a[x]-1;
f>=0;
f--){
var n=a[f];
if((g||b==n[Zc])&&(h||c==n.capture)){
nh(n.key);
e++
}
}
}
}
return e
}
,mh=function(a,b,c){
var e=fh;
if(b in e){
e=e[b];
if(c in e){
e=e[c];
a=Ud(a);
if(e[a])return e[a]
}
}
return j
}
,jh=function(a){
if(a in ih)return ih[a];
return ih[a]=hh+a
}
,sh=function(a,b,c,e,f){
var g=1;
b=Ud(b);
if(a[b]){
a.remaining_--;
a=a[b];
if(a.locked_)a.locked_++;
else a.locked_=1;
try{
for(var h=a[x],n=0;
n<h;
n++){
var o=a[n];
if(o&&!o.removed)g&=rh(o,f)!==k
}
}
finally{
a.locked_--;
oh(c,e,b,a)
}
}
return Boolean(g)
}
,rh=function(a,b){
var c=a[M](b);
a.callOnce&&nh(a.key);
return c
}
,th=function(a,b){
if(!eh[a])return i;
var c=eh[a],e=c[Zc],f=fh;
if(!(e in f))return i;
f=f[e];
var g,h,n;
if(Eg===ba)Eg=X&&!S[Lc];
if(n=Eg){
g=b||Id("window.event");
n=i in f;
var o=k in f;
if(n){
if(g[Dc]<0||g.returnValue!=ba)return i;
a:{
var s=g,A=k;
if(s[Dc]==0)try{
Ka(s,-1);
break a
}
catch(G){
A=i
}
if(A||s.returnValue==ba)s.returnValue=i
}
}
s=ch();
s.init(g,this);
g=i;
try{
if(n){
for(var R=Wg(),L=s[cc];
L;
L=L[O])R[w](L);
h=f[i];
h.remaining_=h.count_;
for(var Qa=R[x]-1;
!s.propagationStopped_&&Qa>=0&&h.remaining_;
Qa--){
Ca(s,R[Qa]);
g&=sh(h,R[Qa],e,i,s)
}
if(o){
h=f[k];
h.remaining_=h.count_;
for(Qa=0;
!s.propagationStopped_&&
Qa<R[x]&&h.remaining_;
Qa++){
Ca(s,R[Qa]);
g&=sh(h,R[Qa],e,k,s)
}
}
}
else g=rh(c,s)
}
finally{
if(R){
pa(R,0);
Xg(R)
}
s.dispose();
dh(s)
}
return g
}
e=new Kg(b,this);
try{
g=rh(c,e)
}
finally{
e.dispose()
}
return g
};
Zg(th);
var uh=function(){
};
U(uh,Hg);
Q=uh[y];
Q.customEvent_=i;
Q.parentEventTarget_=j;
Q.getParentEventTarget=function(){
return this.parentEventTarget_
};
Q.setParentEventTarget=function(a){
this.parentEventTarget_=a
};
Q.addEventListener=function(a,b,c,e){
Y(this,a,b,c,e)
};
Q.removeEventListener=function(a,b,c,e){
lh(this,a,b,c,e)
};
Ba(Q,function(a){
a=a;
if(Od(a))a=new Ig(a,this);
else if(a instanceof Ig)Ea(a,a[I]||this);
else{
var b=a;
a=new Ig(a[Zc],this);
mf(a,b)
}
b=1;
var c,e=a[Zc],f=fh;
if(e in f){
f=f[e];
e=i in f;
var g;
if(e){
c=[];
for(g=this;
g;
g=g.getParentEventTarget())c[w](g);
g=f[i];
g.remaining_=g.count_;
for(var h=c[x]-1;
!a.propagationStopped_&&h>=0&&g.remaining_;
h--){
Ca(a,c[h]);
b&=sh(g,c[h],a[Zc],i,a)&&a.returnValue_!=k
}
}
if(g=k in f){
g=f[k];
g.remaining_=g.count_;
if(e)for(h=0;
!a.propagationStopped_&&h<c[x]&&g.remaining_;
h++){
Ca(a,
c[h]);
b&=sh(g,c[h],a[Zc],k,a)&&a.returnValue_!=k
}
else for(c=this;
!a.propagationStopped_&&c&&g.remaining_;
c=c.getParentEventTarget()){
Ca(a,c);
b&=sh(g,c,a[Zc],k,a)&&a.returnValue_!=k
}
}
a=Boolean(b)
}
else a=i;
return a
}
);
Q.disposeInternal=function(){
uh.superClass_.disposeInternal[J](this);
ph(this);
this.parentEventTarget_=j
};
var vh=function(a){
a=m(a);
var b;
if(/^\s*$/[lb](a))b=k;
else{
b=/\\["\\\/bfnrtu]/g;
var c=/"[^"\\\n\r\u2028\u2029\x00-\x08\x10-\x1f\x80-\x9f]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,e=/(?:^|:|,)(?:[\s\u2028\u2029]*\[)+/g,f=/^[\],:{
}
\s\u2028\u2029]*$/;
b=f[lb](a[B](b,"@")[B](c,"]")[B](e,""))
}
if(b)try{
return eval("("+a+")")
}
catch(g){
}
d(l("Invalid JSON string: "+a))
}
,wh=function(a){
return eval("("+a+")")
}
,xh=function(){
};
xh[y].serialize=function(a){
var b=[];
this.serialize_(a,b);
return b[ud]("")
};
xh[y].serialize_=function(a,b){
switch(typeof a){
case "string":this.serializeString_(a,b);
break;
case "number":this.serializeNumber_(a,b);
break;
case "boolean":b[w](a);
break;
case "undefined":b[w]("null");
break;
case "object":if(a==j){
b[w]("null");
break
}
if(Md(a)){
this.serializeArray_(a,b);
break
}
this.serializeObject_(a,b);
break;
case "function":break;
default:d(l("Unknown type: "+typeof a))
}
};
var yh={
'"':'\\"',"\\":"\\\\","/":"\\/","\u0008":"\\b","\u000c":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\u000b":"\\u000b"
}
,zh=/\uffff/[lb]("\uffff")?/[\\\"\x00-\x1f\x7f-\uffff]/g:/[\\\"\x00-\x1f\x7f-\xff]/g;
xh[y].serializeString_=function(a,b){
b[w]('"',a[B](zh,function(c){
if(c in yh)return yh[c];
var e=c[Jc](0),f="\\u";
if(e<16)f+="000";
else if(e<256)f+="00";
else if(e<4096)f+="0";
return yh[c]=f+e[db](16)
}
),'"')
};
xh[y].serializeNumber_=function(a,b){
b[w](isFinite(a)&&!ia(a)?a:"null")
};
xh[y].serializeArray_=function(a,b){
var c=a[x];
b[w]("[");
for(var e="",f=0;
f<c;
f++){
b[w](e);
this.serialize_(a[f],b);
e=","
}
b[w]("]")
};
xh[y].serializeObject_=function(a,b){
b[w]("{
");
var c="",e;
for(e in a)if(a[Zb](e)){
var f=a[e];
if(typeof f!="function"){
b[w](c);
this.serializeString_(e,b);
b[w](":");
this.serialize_(f,b);
c=","
}
}
b[w]("
}
")
};
var Bh=function(a,b){
this.interval_=a||1;
this.timerObject_=b||Ah;
this.boundTick_=T(this.tick_,this);
this.last_=$d()
};
U(Bh,uh);
Bh[y].enabled=k;
var Ah=S.window,Ch=0.8;
Q=Bh[y];
Q.timer_=j;
Q.setInterval=function(a){
this.interval_=a;
if(this.timer_&&this.enabled){
this[cb]();
this[xc]()
}
else this.timer_&&this[cb]()
};
Q.tick_=function(){
if(this.enabled){
var a=$d()-this.last_;
if(a>0&&a<this.interval_*Ch)this.timer_=this.timerObject_[yb](this.boundTick_,this.interval_-a);
else{
this.dispatchTick();
if(this.enabled){
this.timer_=this.timerObject_[yb](this.boundTick_,this.interval_);
this.last_=$d()
}
}
}
};
Q.dispatchTick=function(){
this[F]("tick")
};
Q.start=function(){
this.enabled=i;
if(!this.timer_){
this.timer_=this.timerObject_[yb](this.boundTick_,this.interval_);
this.last_=$d()
}
};
Q.stop=function(){
this.enabled=k;
if(this.timer_){
this.timerObject_[qb](this.timer_);
this.timer_=j
}
};
Q.disposeInternal=function(){
Bh.superClass_.disposeInternal[J](this);
this[cb]();
delete this.timerObject_
};
var Dh=function(a,b,c){
if(Qd(a)){
if(c)a=T(a,c)
}
else if(a&&typeof a[M]=="function")a=T(a[M],a);
else d(l("Invalid listener argument"));
return b>2147483647?-1:Ah[yb](a,b||0)
};
var Eh=la("^(?:([^:/?#.]+):)?(?://(?:([^/?#]*)@)?([\\w\\d\\-\\u0100-\\uffff.%]*)(?::([0-9]+))?)?([^?#]+)?(?:\\?([^#]*))?(?:#(.*))?$");
var Fh=function(){
if(mg){
this.contextsToXhr_={
};
this.xhrToContexts_={
};
this.stack_=[]
}
};
Q=Fh[y];
Q.logger_=Of("goog.net.xhrMonitor");
Q.enabled_=mg;
Q.setEnabled=function(a){
this.enabled_=mg&&a
};
Q.pushContext=function(a){
if(this.enabled_){
var b=Od(a)?a:Rd(a)?Ud(a):"";
this.logger_.finest("Pushing context: "+a+" ("+b+")");
this.stack_[w](b)
}
};
Q.popContext=function(){
if(this.enabled_){
var a=this.stack_.pop();
this.logger_.finest("Popping context: "+a);
this.updateDependentContexts_(a)
}
};
Q.isContextSafe=function(a){
if(!this.enabled_)return i;
var b=this.contextsToXhr_[Od(a)?a:Rd(a)?Ud(a):""];
this.logger_.fine("Context is safe : "+a+" - "+b);
return!b
};
Q.markXhrOpen=function(a){
if(this.enabled_){
a=Ud(a);
this.logger_.fine("Opening XHR : "+a);
for(var b=0;
b<this.stack_[x];
b++){
var c=this.stack_[b];
this.addToMap_(this.contextsToXhr_,c,a);
this.addToMap_(this.xhrToContexts_,a,c)
}
}
};
Q.markXhrClosed=function(a){
if(this.enabled_){
a=Ud(a);
this.logger_.fine("Closing XHR : "+a);
delete this.xhrToContexts_[a];
for(var b in this.contextsToXhr_){
Se(this.contextsToXhr_[b],a);
this.contextsToXhr_[b][x]==0&&delete this.contextsToXhr_[b]
}
}
};
Q.updateDependentContexts_=function(a){
var b=this.xhrToContexts_[a],c=this.contextsToXhr_[a];
if(b&&c){
this.logger_.finest("Updating dependent contexts");
Le(b,function(e){
Le(c,function(f){
this.addToMap_(this.contextsToXhr_,e,f);
this.addToMap_(this.xhrToContexts_,f,e)
}
,this)
}
,this)
}
};
Q.addToMap_=function(a,b,c){
a[b]||(a[b]=[]);
Qe(a[b],c)||a[b][w](c)
};
var Gh=new Fh;
var Hh=function(){
};
Hh[y].cachedOptions_=j;
Hh[y].getOptions=function(){
return this.cachedOptions_||(this.cachedOptions_=this.internalGetOptions())
};
var Ih=function(a,b){
this.xhrFactory_=a;
this.optionsFactory_=b
};
U(Ih,Hh);
Ih[y].createInstance=function(){
return this.xhrFactory_()
};
Ih[y].getOptions=function(){
return this.optionsFactory_()
};
var Kh=function(){
return Jh.createInstance()
}
,Jh,Lh=function(){
};
U(Lh,Hh);
Lh[y].createInstance=function(){
var a=this.getProgId_();
return a?new ActiveXObject(a):new XMLHttpRequest
};
Lh[y].internalGetOptions=function(){
var a=this.getProgId_(),b={
};
if(a){
b[0]=i;
b[1]=i
}
return b
};
Lh[y].ieProgId_=j;
Lh[y].getProgId_=function(){
if(!this.ieProgId_&&typeof XMLHttpRequest=="undefined"&&typeof ActiveXObject!="undefined"){
for(var a=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","Microsoft.XMLHTTP"],b=0;
b<a[x];
b++){
var c=a[b];
try{
new ActiveXObject(c);
return this.ieProgId_=c
}
catch(e){
}
}
d(l("Could not create ActiveXObject. ActiveX might be disabled, or MSXML might not be installed"))
}
return this.ieProgId_
};
var Mh=new Lh;
Jh=Mh;
var Nh=function(a){
this.headers=new qf;
this.xmlHttpFactory_=a||j
};
U(Nh,uh);
Nh[y].logger_=Of("goog.net.XhrIo");
var Oh=/^https?:?$/i,Ph=[],Rh=function(a,b,c,e,f,g){
var h=new Nh;
Ph[w](h);
b&&Y(h,"complete",b);
Y(h,"ready",Zd(Qh,h));
g&&h.setTimeoutInterval(g);
h[pc](a,c,e,f)
}
,Qh=function(a){
a.dispose();
Se(Ph,a)
};
Q=Nh[y];
Q.active_=k;
Q.xhr_=j;
Q.xhrOptions_=j;
Q.lastUri_="";
Q.lastMethod_="";
Q.lastErrorCode_=0;
Q.lastError_="";
Q.errorDispatched_=k;
Q.inSend_=k;
Q.inOpen_=k;
Q.inAbort_=k;
Q.timeoutInterval_=0;
Q.timeoutId_=j;
Q.setTimeoutInterval=function(a){
this.timeoutInterval_=r.max(0,a)
};
Ha(Q,function(a,b,c,e){
if(this.xhr_)d(l("[goog.net.XhrIo] Object is active with another request"));
b=b||"GET";
this.lastUri_=a;
this.lastError_="";
this.lastErrorCode_=0;
this.lastMethod_=b;
this.errorDispatched_=k;
this.active_=i;
this.xhr_=this.createXhr();
this.xhrOptions_=this.xmlHttpFactory_?this.xmlHttpFactory_.getOptions():Jh.getOptions();
Gh.markXhrOpen(this.xhr_);
oa(this.xhr_,T(this.onReadyStateChange_,this));
try{
this.logger_.fine(this.formatMsg_("Opening Xhr"));
this.inOpen_=i;
this.xhr_[kb](b,a,i);
this.inOpen_=k
}
catch(f){
this.logger_.fine(this.formatMsg_("Error opening Xhr: "+f[Yb]));
this.error_(5,f);
return
}
a=c||"";
var g=this.headers.clone();
e&&pf(e,function(n,o){
g.set(o,n)
}
);
b=="POST"&&!g.containsKey("Content-Type")&&g.set("Content-Type","application/x-www-form-urlencoded;
charset=utf-8");
pf(g,function(n,o){
this.xhr_.setRequestHeader(o,n)
}
,this);
try{
if(this.timeoutId_){
Ah[qb](this.timeoutId_);
this.timeoutId_=j
}
if(this.timeoutInterval_>0){
this.logger_.fine(this.formatMsg_("Will abort after "+
this.timeoutInterval_+"ms if incomplete"));
this.timeoutId_=Ah[yb](T(this.timeout_,this),this.timeoutInterval_)
}
this.logger_.fine(this.formatMsg_("Sending request"));
this.inSend_=i;
this.xhr_[pc](a);
this.inSend_=k
}
catch(h){
this.logger_.fine(this.formatMsg_("Send error: "+h[Yb]));
this.error_(5,h)
}
}
);
Q.createXhr=function(){
return this.xmlHttpFactory_?this.xmlHttpFactory_.createInstance():new Kh
};
Ba(Q,function(a){
if(this.xhr_){
Gh.pushContext(this.xhr_);
try{
return Nh.superClass_[F][J](this,a)
}
finally{
Gh.popContext()
}
}
else return Nh.superClass_[F][J](this,a)
}
);
Q.timeout_=function(){
if(typeof Gd!="undefined")if(this.xhr_){
this.lastError_="Timed out after "+this.timeoutInterval_+"ms, aborting";
this.lastErrorCode_=8;
this.logger_.fine(this.formatMsg_(this.lastError_));
this[F]("timeout");
this[vb](8)
}
};
Q.error_=function(a,b){
this.active_=k;
if(this.xhr_){
this.inAbort_=i;
this.xhr_[vb]();
this.inAbort_=k
}
this.lastError_=b;
this.lastErrorCode_=a;
this.dispatchErrors_();
this.cleanUpXhr_()
};
Q.dispatchErrors_=function(){
if(!this.errorDispatched_){
this.errorDispatched_=i;
this[F]("complete");
this[F]("error")
}
};
Q.abort=function(a){
if(this.xhr_&&this.active_){
this.logger_.fine(this.formatMsg_("Aborting"));
this.active_=k;
this.inAbort_=i;
this.xhr_[vb]();
this.inAbort_=k;
this.lastErrorCode_=a||7;
this[F]("complete");
this[F]("abort");
this.cleanUpXhr_()
}
};
Q.disposeInternal=function(){
if(this.xhr_){
if(this.active_){
this.active_=k;
this.inAbort_=i;
this.xhr_[vb]();
this.inAbort_=k
}
this.cleanUpXhr_(i)
}
Nh.superClass_.disposeInternal[J](this)
};
Q.onReadyStateChange_=function(){
!this.inOpen_&&!this.inSend_&&!this.inAbort_?this.onReadyStateChangeEntryPoint_():this.onReadyStateChangeHelper_()
};
Q.onReadyStateChangeEntryPoint_=function(){
this.onReadyStateChangeHelper_()
};
Q.onReadyStateChangeHelper_=function(){
if(this.active_)if(typeof Gd!="undefined")if(this.xhrOptions_[1]&&this.getReadyState()==4&&this.getStatus()==2)this.logger_.fine(this.formatMsg_("Local request error detected and ignored"));
else if(this.inSend_&&this.getReadyState()==4)Ah[yb](T(this.onReadyStateChange_,this),0);
else{
this[F]("readystatechange");
if(this.isComplete()){
this.logger_.fine(this.formatMsg_("Request complete"));
this.active_=k;
if(this.isSuccess()){
this[F]("complete");
this[F]("success")
}
else{
this.lastErrorCode_=
6;
this.lastError_=this.getStatusText()+" ["+this.getStatus()+"]";
this.dispatchErrors_()
}
this.cleanUpXhr_()
}
}
};
Q.cleanUpXhr_=function(a){
if(this.xhr_){
var b=this.xhr_,c=this.xhrOptions_[0]?Jd:j;
this.xhrOptions_=this.xhr_=j;
if(this.timeoutId_){
Ah[qb](this.timeoutId_);
this.timeoutId_=j
}
if(!a){
Gh.pushContext(b);
this[F]("ready");
Gh.popContext()
}
Gh.markXhrClosed(b);
try{
oa(b,c)
}
catch(e){
this.logger_.severe("Problem encountered resetting onreadystatechange: "+e[Yb])
}
}
};
Q.isActive=function(){
return!!this.xhr_
};
Q.isComplete=function(){
return this.getReadyState()==4
};
Q.isSuccess=function(){
switch(this.getStatus()){
case 0:return!this.isLastUriEffectiveSchemeHttp_();
case 200:case 204:case 304:return i;
default:return k
}
};
Q.isLastUriEffectiveSchemeHttp_=function(){
var a=Od(this.lastUri_)?this.lastUri_[nc](Eh)[1]||j:this.lastUri_.getScheme();
if(a)return Oh[lb](a);
return self[Rb]?Oh[lb](self[Rb].protocol):i
};
Q.getReadyState=function(){
return this.xhr_?this.xhr_[sc]:0
};
Q.getStatus=function(){
try{
return this.getReadyState()>2?this.xhr_.status:-1
}
catch(a){
this.logger_.warning("Can not get status: "+a[Yb]);
return-1
}
};
Q.getStatusText=function(){
try{
return this.getReadyState()>2?this.xhr_.statusText:""
}
catch(a){
this.logger_.fine("Can not get status: "+a[Yb]);
return""
}
};
Q.getLastUri=function(){
return m(this.lastUri_)
};
Q.getResponseText=function(){
try{
return this.xhr_?this.xhr_.responseText:""
}
catch(a){
this.logger_.fine("Can not get responseText: "+a[Yb]);
return""
}
};
Q.getResponseXml=function(){
try{
return this.xhr_?this.xhr_.responseXML:j
}
catch(a){
this.logger_.fine("Can not get responseXML: "+a[Yb]);
return j
}
};
Q.getResponseJson=function(a){
if(this.xhr_){
var b=this.xhr_.responseText;
if(a&&b[E](a)==0)b=b[Sc](a[x]);
return vh(b)
}
};
Q.getResponseHeader=function(a){
return this.xhr_&&this.isComplete()?this.xhr_.getResponseHeader(a):ba
};
Q.getAllResponseHeaders=function(){
return this.xhr_&&this.isComplete()?this.xhr_.getAllResponseHeaders():""
};
Q.getLastErrorCode=function(){
return this.lastErrorCode_
};
Q.formatMsg_=function(a){
return a+" ["+this.lastMethod_+" "+this.lastUri_+" "+this.getStatus()+"]"
};
var Sh=function(a,b){
var c;
if(a instanceof Sh){
this.setIgnoreCase(b==j?a.getIgnoreCase():b);
this.setScheme(a.getScheme());
this.setUserInfo(a.getUserInfo());
this.setDomain(a.getDomain());
this.setPort(a.getPort());
this.setPath(a.getPath());
this.setQueryData(a.getQueryData().clone());
this.setFragment(a.getFragment())
}
else if(a&&(c=m(a)[nc](Eh))){
this.setIgnoreCase(!!b);
this.setScheme(c[1]||"",i);
this.setUserInfo(c[2]||"",i);
this.setDomain(c[3]||"",i);
this.setPort(c[4]);
this.setPath(c[5]||"",i);
this.setQuery(c[6]||
"",i);
this.setFragment(c[7]||"",i)
}
else{
this.setIgnoreCase(!!b);
this.queryData_=new Th(j,this,this.ignoreCase_)
}
};
Q=Sh[y];
Q.scheme_="";
Q.userInfo_="";
Q.domain_="";
Q.port_=j;
Q.path_="";
Q.fragment_="";
Q.isReadOnly_=k;
Q.ignoreCase_=k;
na(Q,function(){
if(this.cachedToString_)return this.cachedToString_;
var a=[];
this.scheme_&&a[w](Uh(this.scheme_,Vh),":");
if(this.domain_){
a[w]("//");
this.userInfo_&&a[w](Uh(this.userInfo_,Vh),"@");
a[w](Wh(this.domain_));
this.port_!=j&&a[w](":",m(this.getPort()))
}
if(this.path_){
this.hasDomain()&&this.path_[Lb](0)!="/"&&a[w]("/");
a[w](Uh(this.path_,Xh))
}
var b=m(this.queryData_);
b&&a[w]("?",b);
this.fragment_&&a[w]("#",Uh(this.fragment_,Yh));
return this.cachedToString_=a[ud]("")
}
);
Q.resolve=function(a){
var b=this.clone(),c=a.hasScheme();
if(c)b.setScheme(a.getScheme());
else c=a.hasUserInfo();
if(c)b.setUserInfo(a.getUserInfo());
else c=a.hasDomain();
if(c)b.setDomain(a.getDomain());
else c=a.hasPort();
var e=a.getPath();
if(c)b.setPort(a.getPort());
else if(c=a.hasPath()){
if(e[Lb](0)!="/")if(this.hasDomain()&&!this.hasPath())e="/"+e;
else{
var f=b.getPath()[yc]("/");
if(f!=-1)e=b.getPath()[Ed](0,f+1)+e
}
e=Zh(e)
}
if(c)b.setPath(e);
else c=a.hasQuery();
if(c)b.setQuery(a.getDecodedQuery());
else c=a.hasFragment();
c&&b.setFragment(a.getFragment());
return b
};
Q.clone=function(){
var a;
a=this.scheme_;
var b=this.userInfo_,c=this.domain_,e=this.port_,f=this.path_,g=this.queryData_.clone(),h=this.fragment_,n=new Sh(j,this.ignoreCase_);
a&&n.setScheme(a);
b&&n.setUserInfo(b);
c&&n.setDomain(c);
e&&n.setPort(e);
f&&n.setPath(f);
g&&n.setQueryData(g);
h&&n.setFragment(h);
return a=n
};
Q.getScheme=function(){
return this.scheme_
};
Q.setScheme=function(a,b){
this.enforceReadOnly();
delete this.cachedToString_;
if(this.scheme_=b?a?ha(a):"":a)this.scheme_=this.scheme_[B](/:$/,"");
return this
};
Q.hasScheme=function(){
return!!this.scheme_
};
Q.getUserInfo=function(){
return this.userInfo_
};
Q.setUserInfo=function(a,b){
this.enforceReadOnly();
delete this.cachedToString_;
this.userInfo_=b?a?ha(a):"":a;
return this
};
Q.hasUserInfo=function(){
return!!this.userInfo_
};
Q.getDomain=function(){
return this.domain_
};
Q.setDomain=function(a,b){
this.enforceReadOnly();
delete this.cachedToString_;
this.domain_=b?a?ha(a):"":a;
return this
};
Q.hasDomain=function(){
return!!this.domain_
};
Q.getPort=function(){
return this.port_
};
Q.setPort=function(a){
this.enforceReadOnly();
delete this.cachedToString_;
if(a){
a=fa(a);
if(ia(a)||a<0)d(l("Bad port number "+a));
this.port_=a
}
else this.port_=j;
return this
};
Q.hasPort=function(){
return this.port_!=j
};
Q.getPath=function(){
return this.path_
};
Q.setPath=function(a,b){
this.enforceReadOnly();
delete this.cachedToString_;
this.path_=b?a?ha(a):"":a;
return this
};
Q.hasPath=function(){
return!!this.path_
};
Q.hasQuery=function(){
return this.queryData_[db]()!==""
};
Q.setQueryData=function(a,b){
this.enforceReadOnly();
delete this.cachedToString_;
if(a instanceof Th){
this.queryData_=a;
this.queryData_.uri_=this;
this.queryData_.setIgnoreCase(this.ignoreCase_)
}
else{
b||(a=Uh(a,$h));
this.queryData_=new Th(a,this,this.ignoreCase_)
}
return this
};
Q.setQuery=function(a,b){
return this.setQueryData(a,b)
};
Q.getEncodedQuery=function(){
return this.queryData_[db]()
};
Q.getDecodedQuery=function(){
return this.queryData_.toDecodedString()
};
Q.getQueryData=function(){
return this.queryData_
};
Q.getQuery=function(){
return this.getEncodedQuery()
};
Q.setParameterValue=function(a,b){
this.enforceReadOnly();
delete this.cachedToString_;
this.queryData_.set(a,b);
return this
};
Q.setParameterValues=function(a,b){
this.enforceReadOnly();
delete this.cachedToString_;
Md(b)||(b=[m(b)]);
this.queryData_.setValues(a,b);
return this
};
Q.getParameterValue=function(a){
return this.queryData_.get(a)
};
Q.getFragment=function(){
return this.fragment_
};
Q.setFragment=function(a,b){
this.enforceReadOnly();
delete this.cachedToString_;
this.fragment_=b?a?ha(a):"":a;
return this
};
Q.hasFragment=function(){
return!!this.fragment_
};
Q.makeUnique=function(){
this.enforceReadOnly();
this.setParameterValue("zx",Be());
return this
};
Q.removeParameter=function(a){
this.enforceReadOnly();
this.queryData_[wc](a);
return this
};
Q.enforceReadOnly=function(){
if(this.isReadOnly_)d(l("Tried to modify a read-only Uri"))
};
Q.setIgnoreCase=function(a){
this.ignoreCase_=a;
this.queryData_&&this.queryData_.setIgnoreCase(a)
};
Q.getIgnoreCase=function(){
return this.ignoreCase_
};
var ai=function(a,b){
return a instanceof Sh?a.clone():new Sh(a,b)
}
,Zh=function(a){
if(a==".."||a==".")return"";
else if(!ve(a,"./")&&!ve(a,"/."))return a;
else{
var b=be(a,"/");
a=a[Fb]("/");
for(var c=[],e=0;
e<a[x];
){
var f=a[e++];
if(f==".")b&&e==a[x]&&c[w]("");
else if(f==".."){
if(c[x]>1||c[x]==1&&c[0]!="")c.pop();
b&&e==a[x]&&c[w]("")
}
else{
c[w](f);
b=i
}
}
return c[ud]("/")
}
}
,Wh=function(a){
if(Od(a))return ca(a);
return j
}
,bi=/^[a-zA-Z0-9\-_.!~*'():\/;
?]*$/,Uh=function(a,b){
    var c=j;
    if(Od(a)){
        c=a;
        bi[lb](c)||
        (c=encodeURI(a));
        if(c.search(b)>=0)c=c[B](b,ci)
    }
    return c
}
,ci=function(a){
    a=a[Jc](0);
    return"%"+(a>>4&15)[db](16)+(a&15)[db](16)
}
,Vh=/[#\/\?@]/g,Xh=/[\#\?]/g,$h=/[\#\?@]/g,Yh=/#/g,Th=function(a,b,c){
    this.encodedQuery_=a||j;
    this.uri_=b||j;
    this.ignoreCase_=!!c
};
Q=Th[y];
Q.ensureKeyMapInitialized_=function(){
if(!this.keyMap_){
    this.keyMap_=new qf;
    if(this.encodedQuery_)for(var a=this.encodedQuery_[Fb]("&"),b=0;
    b<a[x];
    b++){
        var c=a[b][E]("="),e=j,f=j;
        if(c>=0){
            e=a[b][Sc](0,c);
            f=a[b][Sc](c+1)
        }
        else e=a[b];
        e=ha(e[B](/\+/g," "));
        e=this.getKeyName_(e);
        this.add(e,f?ha(f[B](/\+/g," ")):"")
    }
}
};
Q.keyMap_=j;
Q.count_=j;
Q.getCount=function(){
this.ensureKeyMapInitialized_();
return this.count_
};
Q.add=function(a,b){
this.ensureKeyMapInitialized_();
this.invalidateCache_();
a=this.getKeyName_(a);
if(this.containsKey(a)){
    var c=this.keyMap_.get(a);
    Md(c)?c[w](b):this.keyMap_.set(a,[c,b])
}
else this.keyMap_.set(a,b);
this.count_++;
return this
};
Ia(Q,function(a){
this.ensureKeyMapInitialized_();
a=this.getKeyName_(a);
if(this.keyMap_.containsKey(a)){
    this.invalidateCache_();
    var b=this.keyMap_.get(a);
    if(Md(b))this.count_-=b[x];
    else this.count_--;
    return this.keyMap_[wc](a)
}
return k
}
);
Ra(Q,function(){
this.invalidateCache_();
this.keyMap_&&this.keyMap_[ad]();
this.count_=0
}
);
Q.isEmpty=function(){
this.ensureKeyMapInitialized_();
return this.count_==0
};
Q.containsKey=function(a){
this.ensureKeyMapInitialized_();
a=this.getKeyName_(a);
return this.keyMap_.containsKey(a)
};
Q.getKeys=function(){
this.ensureKeyMapInitialized_();
for(var a=this.keyMap_.getValues(),b=this.keyMap_.getKeys(),c=[],e=0;
e<b[x];
e++){
    var f=a[e];
    if(Md(f))for(var g=0;
    g<f[x];
    g++)c[w](b[e]);
    else c[w](b[e])
}
return c
};
Q.getValues=function(a){
this.ensureKeyMapInitialized_();
if(a){
    a=this.getKeyName_(a);
    if(this.containsKey(a)){
        var b=this.keyMap_.get(a);
        if(Md(b))return b;
        else{
            a=[];
            a[w](b)
        }
    }
    else a=[]
}
else{
    b=this.keyMap_.getValues();
    a=[];
    for(var c=0;
    c<b[x];
    c++){
        var e=b[c];
        Md(e)?Ve(a,e):a[w](e)
    }
}
return a
};
Q.set=function(a,b){
this.ensureKeyMapInitialized_();
this.invalidateCache_();
a=this.getKeyName_(a);
if(this.containsKey(a)){
    var c=this.keyMap_.get(a);
    if(Md(c))this.count_-=c[x];
    else this.count_--
}
this.keyMap_.set(a,b);
this.count_++;
return this
};
Q.get=function(a,b){
this.ensureKeyMapInitialized_();
a=this.getKeyName_(a);
if(this.containsKey(a)){
    var c=this.keyMap_.get(a);
    return Md(c)?c[0]:c
}
else return b
};
Q.setValues=function(a,b){
this.ensureKeyMapInitialized_();
this.invalidateCache_();
a=this.getKeyName_(a);
if(this.containsKey(a)){
    var c=this.keyMap_.get(a);
    if(Md(c))this.count_-=c[x];
    else this.count_--
}
if(b[x]>0){
    this.keyMap_.set(a,b);
    this.count_+=b[x]
}
};
na(Q,function(){
if(this.encodedQuery_)return this.encodedQuery_;
if(!this.keyMap_)return"";
for(var a=[],b=0,c=this.keyMap_.getKeys(),e=0;
e<c[x];
e++){
    var f=c[e],g=le(f);
    f=this.keyMap_.get(f);
    if(Md(f))for(var h=0;
    h<f[x];
    h++){
        b>0&&a[w]("&");
        a[w](g);
        f[h]!==""&&a[w]("=",le(f[h]));
        b++
    }
    else{
        b>0&&a[w]("&");
        a[w](g);
        f!==""&&a[w]("=",le(f));
        b++
    }
}
return this.encodedQuery_=a[ud]("")
}
);
Q.toDecodedString=function(){
if(!this.decodedQuery_)this.decodedQuery_=this[db]()?ha(this[db]()):"";
return this.decodedQuery_
};
Q.invalidateCache_=function(){
delete this.decodedQuery_;
delete this.encodedQuery_;
this.uri_&&delete this.uri_.cachedToString_
};
Q.clone=function(){
var a=new Th;
if(this.decodedQuery_)a.decodedQuery_=this.decodedQuery_;
if(this.encodedQuery_)a.encodedQuery_=this.encodedQuery_;
if(this.keyMap_)a.keyMap_=this.keyMap_.clone();
return a
};
Q.getKeyName_=function(a){
a=m(a);
if(this.ignoreCase_)a=a[zd]();
return a
};
Q.setIgnoreCase=function(a){
var b=a&&!this.ignoreCase_;
if(b){
    this.ensureKeyMapInitialized_();
    this.invalidateCache_();
    pf(this.keyMap_,function(c,e){
        var f=e[zd]();
        if(e!=f){
            this[wc](e);
            this.add(f,c)
        }
    }
    ,this)
}
this.ignoreCase_=a
};
Q.extend=function(){
for(var a=0;
a<arguments[x];
a++){
    var b=arguments[a];
    pf(b,function(c,e){
        this.add(e,c)
    }
    ,this)
}
};
var di=function(a,b){
if(!a)d(l("Cannot create a fast data node without a data name"));
this.__dataName=a;
this.__parent=b
};
di[y].getDataName=function(){
return this.__dataName
};
di[y].setDataName=function(a){
this.__dataName=a
};
di[y].getDataPath=function(){
var a;
a=this.__parent?this.__parent.getDataPath()+"/":"";
return a+this.getDataName()
};
var ei=function(a,b,c){
di[J](this,b,c);
this.extendWith_(a)
};
U(ei,di);
ei[y].extendWith_=function(a){
for(var b in a)this[b]=a[b]
};
var hi=function(a,b,c){
return Md(a)?new fi(a,b,c):Rd(a)?new ei(a,b,c):new gi(a||!!a,b,c)
}
,ii=new Rf;
Q=ei[y];
Q.set=function(){
d("Not implemented yet")
};
Q.getChildNodes=function(a){
if(!a||a=="*")return this;
else if(a[E]("*")==-1)return(a=this.getChildNode(a))?new fi([a],""):new Rf;
else d(l("Unsupported selector: "+a))
};
Q.wrapChild_=function(a){
var b=this[a];
if(b!=j&&!b.getDataName)this[a]=hi(this[a],a,this)
};
Q.getChildNode=function(a,b){
this.wrapChild_(a);
var c=this[a]||j;
if(c==j&&b){
    c=new ei({
    }
    ,a,this);
    this[a]=c
}
return c
};
Q.setChildNode=function(a,b){
if(b!=j)this[a]=b;
else delete this[a];
V().fireDataChange(this.getDataPath()+"/"+a);
return j
};
Q.getChildNodeValue=function(a){
a=this[a];
return a!=j?a.getDataName?a.get():a:j
};
Q.isList=function(){
return k
};
Q.getJsObject=function(){
var a={
}
,b;
for(b in this)if(!be(b,"__")&&!Qd(this[b]))a[b]=this[b].__dataName?this[b].getJsObject():this[b];
return a
};
Q.clone=function(){
return hi(this.getJsObject(),this.getDataName())
};
Q.add=function(a){
this.setChildNode(a.getDataName(),a)
};
Q.get=function(a){
return a!==ba?this.getChildNode(a):this
};
Q.getByIndex=function(a){
var b=0,c;
for(c in this)if(!be(c,"__")&&!Qd(this[c])){
    if(b==a){
        this.wrapChild_(c);
        return this[c]
    }
    ++b
}
return j
};
Q.getCount=function(){
var a=0,b;
for(b in this)!be(b,"__")&&!Qd(this[b])&&++a;
return a
};
Q.setNode=function(a,b){
this.setChildNode(a,b)
};
Ma(Q,function(a){
delete this[a];
return k
}
);
var gi=function(a,b,c){
this.value_=a;
di[J](this,b,c)
};
U(gi,di);
Q=gi[y];
Q.get=function(){
return this.value_
};
Q.set=function(a){
if(Md(a)||Rd(a))d("can only set PrimitiveFastDataNode to primitive values");
this.value_=a;
V().fireDataChange(this.getDataPath())
};
Q.getChildNodes=function(){
return ii
};
Q.getChildNode=function(){
return j
};
Q.getChildNodeValue=function(){
return j
};
Q.setChildNode=function(){
d(l("Cannot set a child node for a PrimitiveFastDataNode"))
};
Q.isList=function(){
return k
};
Q.getJsObject=function(){
return this.value_
};
var fi=function(a,b,c){
this.values_=[];
for(var e=0;
e<a[x];
++e){
    var f=a[e].id||"["+e+"]";
    this.values_[w](hi(a[e],f,this));
    if(a[e].id){
        if(!this.map_)this.map_={
        }
        ;
        this.map_[a[e].id]=e
    }
}
di[J](this,b,c)
};
U(fi,di);
Q=fi[y];
Q.set=function(){
d(l("Cannot set a FastListNode to a new value"))
};
Q.getChildNodes=function(){
return this
};
Q.getChildNode=function(a,b){
var c=this.getKeyAsNumber_(a);
if(c==j&&this.map_)c=this.map_[a];
if(c!=j&&this.values_[c])return this.values_[c];
else if(b){
    this.setChildNode(a,{
    }
    );
    return this.getChildNode(a)
}
else return j
};
Q.getChildNodeValue=function(a){
return(a=this.getChildNode(a))?a.get():j
};
Q.getKeyAsNumber_=function(a){
return a[Lb](0)=="["&&a[Lb](a[x]-1)=="]"?fa(a[Sc](1,a[x]-1)):j
};
Q.setChildNode=function(a,b){
var c=this.values_[x];
if(b!=j){
    b.getDataName||(b=hi(b,a,this));
    var e=this.getKeyAsNumber_(a);
    if(e!=j){
        if(e<0||e>=this.values_[x])d(l("List index out of bounds: "+e));
        this.values_[a]=b
    }
    else{
        if(!this.map_)this.map_={
        }
        ;
        this.values_[w](b);
        this.map_[a]=this.values_[x]-1
    }
}
else this[Uc](a);
e=V();
e.fireDataChange(this.getDataPath()+"/"+a);
this.values_[x]!=c&&this.listSizeChanged_();
return j
};
Q.listSizeChanged_=function(){
var a=V();
a.fireDataChange(this.getDataPath());
a.fireDataChange(this.getDataPath()+"/count()")
};
Q.isList=function(){
return i
};
Q.getJsObject=function(){
for(var a=[],b=0;
b<this.values_[x];
++b)a[w](this.values_[b].getJsObject());
return a
};
Q.add=function(a){
a.getDataName||(a=hi(a,m("["+this.values_[x]+"]"),this));
this.values_[w](a);
a=V();
a.fireDataChange(this.getDataPath()+"/["+(this.values_[x]-1)+"]");
this.listSizeChanged_()
};
Q.get=function(a){
return a!==ba?this.getChildNode(a):this.values_
};
Q.getByIndex=function(a){
a=this.values_[a];
return a!=j?a:j
};
Q.getCount=function(){
return this.values_[x]
};
Q.setNode=function(){
d(l("Setting child nodes of a FastListNode is not implemented, yet"))
};
Ma(Q,function(a){
var b=this.getKeyAsNumber_(a);
if(b==j&&this.map_)b=this.map_[a];
if(b!=j){
    this.values_[rd](b,1);
    if(this.map_){
        a=j;
        for(var c in this.map_)if(this.map_[c]==b)a=c;
        else this.map_[c]>b&&--this.map_[c];
        a&&delete this.map_[a]
    }
    c=V();
    c.fireDataChange(this.getDataPath()+"/["+b+"]");
    this.listSizeChanged_()
}
return k
}
);
Q.indexOf=function(a){
var b=this.getKeyAsNumber_(a);
if(b==j&&this.map_)b=this.map_[a];
if(b==j)d(l("Cannot determine index for: "+a));
return b
};
var ji=function(a,b,c,e,f){
ei[J](this,{
}
,b,j);
if(a){
    this.uri_=new Sh(a);
    this.xhr_=new Nh;
    this.usePost_=!!f;
    Y(this.xhr_,"complete",this.completed_,k,this)
}
else this.uri_=j;
this.startText_=c;
this.endText_=e
};
U(ji,ei);
ji[y].setQueryData=function(a){
this.queryData_=a
};
wa(ji[y],function(){
Uf.info("Sending JS request for DataSource "+this.getDataName()+" to "+this.uri_);
if(this.uri_)if(this.usePost_){
    var a;
    a=this.queryData_?this.queryData_:this.uri_.getQueryData()[db]();
    var b=this.uri_.clone();
    b.setQueryData(j);
    this.xhr_[pc](m(b),"POST",a)
}
else this.xhr_[pc](m(this.uri_));
else this.loadState_="NOT_LOADED"
}
);
ji[y].success_=function(){
V().fireDataChange(this.getDataName())
};
ji[y].completed_=function(){
if(this.xhr_.isSuccess()){
    Uf.info("Got data for DataSource "+this.getDataName());
    var a=this.xhr_.getResponseText();
    if(this.startText_){
        var b=a[E](this.startText_);
        a=a[Sc](b+this.startText_[x])
    }
    if(this.endText_){
        b=a[yc](this.endText_);
        a=a[Sc](0,b)
    }
    try{
        var c=eval("["+a+"][0]");
        this.extendWith_(c);
        this.loadState_="LOADED"
    }
    catch(e){
        this.loadState_="FAILED";
        Uf.severe("Failed to parse data: "+e[Yb])
    }
    S[yb](T(this.success_,this),0)
}
else{
    Uf.info("Data retrieve failed for DataSource "+
    this.getDataName());
    this.loadState_="FAILED"
}
};
var ki=function(a,b){
this.x=a!==ba?a:0;
this.y=b!==ba?b:0
};
ki[y].clone=function(){
return new ki(this.x,this.y)
};
na(ki[y],function(){
return"("+this.x+", "+this.y+")"
}
);
var li=function(a,b){
return new ki(a.x-b.x,a.y-b.y)
};
var mi=function(a,b){
ta(this,a);
Xa(this,b)
}
,ni=function(a,b){
if(a==b)return i;
if(!a||!b)return k;
return a[z]==b[z]&&a[P]==b[P]
};
Q=mi[y];
Q.clone=function(){
return new mi(this[z],this[P])
};
na(Q,function(){
return"("+this[z]+" x "+this[P]+")"
}
);
Q.area=function(){
return this[z]*this[P]
};
Q.aspectRatio=function(){
return this[z]/this[P]
};
Q.isEmpty=function(){
return!this.area()
};
Q.ceil=function(){
ta(this,r.ceil(this[z]));
Xa(this,r.ceil(this[P]));
return this
};
Q.fitsInside=function(a){
return this[z]<=a[z]&&this[P]<=a[P]
};
Q.floor=function(){
ta(this,r[Gb](this[z]));
Xa(this,r[Gb](this[P]));
return this
};
Q.round=function(){
ta(this,r[ub](this[z]));
Xa(this,r[ub](this[P]));
return this
};
Q.scale=function(a){
this.width*=a;
this.height*=a;
return this
};
Q.scaleToFit=function(a){
a=this.aspectRatio()>a.aspectRatio()?a[z]/this[z]:a[P]/this[P];
return this.scale(a)
};
var oi,pi=!X||Dg("9"),qi=X&&!Dg("9"),ri=X;
var si=function(a,b){
t(a,b)
}
,ti=function(a){
return(a=a[ob])&&typeof a[Fb]=="function"?a[Fb](/\s+/):[]
}
,ui=function(a){
var b=ti(a),c=We(arguments,1),e;
e=b;
c=c;
for(var f=0,g=0;
g<c[x];
g++)if(!Qe(e,c[g])){
    e[w](c[g]);
    f++
}
e=f==c[x];
t(a,b[ud](" "));
return e
}
,vi=function(a){
var b=ti(a),c=We(arguments,1),e;
e=b;
c=c;
for(var f=0,g=0;
g<e[x];
g++)if(Qe(c,e[g])){
    Xe(e,g--,1);
    f++
}
e=f==c[x];
t(a,b[ud](" "));
return e
};
var yi=function(a){
return a?new wi(xi(a)):oi||(oi=new wi)
}
,zi=function(a){
return Od(a)?q[Ib](a):a
}
,Z=zi,Bi=function(a,b,c){
return Ai(q,a,b,c)
}
,Ai=function(a,b,c,e){
a=e||a;
b=b&&b!="*"?b[qd]():"";
if(a.querySelectorAll&&a.querySelector&&(!ng||Ci(q)||Dg("528"))&&(b||c)){
    c=b+(c?"."+c:"");
    return a.querySelectorAll(c)
}
if(c&&a.getElementsByClassName){
    a=a.getElementsByClassName(c);
    if(b){
        e={
        }
        ;
        for(var f=0,g=0,h;
        h=a[g];
        g++)if(b==h[bc])e[f++]=h;
        pa(e,f);
        return e
    }
    else return a
}
a=a[xd](b||"*");
if(c){
    e={
    }
    ;
    for(g=f=
    0;
    h=a[g];
    g++){
        b=h[ob];
        if(typeof b[Fb]=="function"&&Qe(b[Fb](/\s+/),c))e[f++]=h
    }
    pa(e,f);
    return e
}
else return a
}
,Di=Bi,Fi=function(a,b){
df(b,function(c,e){
    if(e=="style")a[H].cssText=c;
    else if(e=="class")t(a,c);
    else if(e=="for")a.htmlFor=c;
    else if(e in Ei)a[Pc](Ei[e],c);
    else a[e]=c
}
)
}
,Ei={
cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",height:"height",width:"width",usemap:"useMap",frameborder:"frameBorder",type:"type"
}
,Gi=function(a){
var b=a[Ab];
if(ng&&!Dg("500")&&!og){
    if(typeof a.innerHeight=="undefined")a=p;
    b=a.innerHeight;
    var c=a[Ab][Dd][Cc];
    if(a==a.top)if(c<b)b-=15;
    return new mi(a.innerWidth,b)
}
a=Ci(b);
if(lg&&!Dg("9.50"))a=k;
a=a?b[Dd]:b[dc];
return new mi(a[tb],a[Hc])
}
,Hi=function(a){
a=a||S||p;
return yi(a[Ab]).getDocumentScroll()
}
,Ii=function(a){
return a?a.parentWindow||a[fd]:p
}
,Ki=function(){
return Ji(q,arguments)
}
,Ji=function(a,b){
var c=b[0],e=b[1];
if(!pi&&e&&(e[N]||e[Zc])){
    c=["<",c];
    e[N]&&c[w](' name="',se(e[N]),'"');
    if(e[Zc]){
        c[w](' type="',
        se(e[Zc]),'"');
        var f={
        }
        ;
        mf(f,e);
        e=f;
        delete e[Zc]
    }
    c[w](">");
    c=c[ud]("")
}
c=a[K](c);
if(e)if(Od(e))t(c,e);
else Md(e)?ui[$c](j,[c][Kb](e)):Fi(c,e);
b[x]>2&&Li(a,c,b,2);
return c
}
,Li=function(a,b,c,e){
function f(h){
    if(h)b[v](Od(h)?a[Nb](h):h)
}
for(e=e;
e<c[x];
e++){
    var g=c[e];
    Nd(g)&&!(Rd(g)&&g[zb]>0)?Le(Mi(g)?Ue(g):g,f):f(g)
}
}
,Ni=function(a){
var b;
b=q;
var c=a;
a=b[K]("div");
if(ri){
    xa(a,"<br>"+c);
    a[hc](a[Ec])
}
else xa(a,c);
if(a[bd][x]==1)b=a[hc](a[Ec]);
else{
    for(b=b.createDocumentFragment();
    a[Ec];
    )b[v](a[Ec]);
    b=
    b
}
return b
}
,Ci=function(a){
return a.compatMode=="CSS1Compat"
}
,Oi=function(a,b){
a[v](b)
}
,Pi=function(a){
Li(xi(a),a,arguments,1)
}
,Qi=function(a){
for(var b;
b=a[Ec];
)a[hc](b)
}
,Ri=function(a){
return a&&a[O]?a[O][hc](a):j
}
,Si=function(a,b){
var c=b[O];
c&&c[pb](a,b)
}
,Ti=function(a){
for(a=a[Ec];
a&&a[zb]!=1;
)a=a[md];
return a=a
}
,Ui=function(a,b){
if(a.contains&&b[zb]==1)return a==b||a.contains(b);
if(typeof a.compareDocumentPosition!="undefined")return a==b||Boolean(a.compareDocumentPosition(b)&16);
for(;
b&&a!=
b;
)b=b[O];
return b==a
}
,xi=function(a){
return a[zb]==9?a:a[fc]||a[Ab]
}
,Vi=function(a){
return a=ng?a[Ab]||a[pd][Ab]:a.contentDocument||a[pd][Ab]
}
,Wi=function(a,b){
if("textContent"in a)a.textContent=b;
else if(a[Ec]&&a[Ec][zb]==3){
    for(;
    a[lc]!=a[Ec];
    )a[hc](a[lc]);
    a[Ec].data=b
}
else{
    Qi(a);
    var c=xi(a);
    a[v](c[Nb](b))
}
}
,Xi={
SCRIPT:1,STYLE:1,HEAD:1,IFRAME:1,OBJECT:1
}
,Yi={
IMG:" ",BR:"\n"
}
,Zi=function(a){
var b=a.getAttributeNode("tabindex");
if(b&&b.specified){
    a=a.tabIndex;
    return Pd(a)&&a>=0
}
return k
}
,aj=function(a){
if(qi&&
        "innerText"in a)a=ie(a.innerText);
else{
    var b=[];
    $i(a,b,i);
    a=b[ud]("")
}
a=a[B](/ \xAD /g," ")[B](/\xAD/g,"");
X||(a=a[B](/ +/g," "));
if(a!=" ")a=a[B](/^\s*/,"");
return a
}
,$i=function(a,b,c){
if(!(a[bc]in Xi))if(a[zb]==3)c?b[w](m(a[yd])[B](/(\r\n|\r|\n)/g,"")):b[w](a[yd]);
else if(a[bc]in Yi)b[w](Yi[a[bc]]);
else for(a=a[Ec];
a;
){
    $i(a,b,c);
    a=a[md]
}
}
,Mi=function(a){
if(a&&typeof a[x]=="number")if(Rd(a))return typeof a[Tb]=="function"||typeof a[Tb]=="string";
else if(Qd(a))return typeof a[Tb]=="function";
return k
}
,
wi=function(a){
this.document_=a||S[Ab]||q
};
Q=wi[y];
Q.getDomHelper=yi;
Q.getDocument=function(){
return this.document_
};
Q.getElement=function(a){
return Od(a)?this.document_[Ib](a):a
};
Q.$=wi[y].getElement;
Q.getElementsByTagNameAndClass=function(a,b,c){
return Ai(this.document_,a,b,c)
};
Q.getViewportSize=function(a){
return Gi(a||this.getWindow()||p)
};
Q.createDom=function(){
return Ji(this.document_,arguments)
};
Q.createElement=function(a){
return this.document_[K](a)
};
Q.createTextNode=function(a){
return this.document_[Nb](a)
};
Q.isCss1CompatMode=function(){
return Ci(this.document_)
};
Q.getWindow=function(){
return this.document_.parentWindow||this.document_[fd]
};
Q.getDocumentScrollElement=function(){
return!ng&&Ci(this.document_)?this.document_[Dd]:this.document_[dc]
};
Q.getDocumentScroll=function(){
var a;
a=!ng&&Ci(this.document_)?this.document_[Dd]:this.document_[dc];
return a=new ki(a[Ic],a[bb])
};
Q.appendChild=Oi;
Q.append=Pi;
Q.removeChildren=Qi;
Ma(Q,Ri);
Q.replaceNode=Si;
Q.getFirstElementChild=Ti;
Pa(Q,Ui);
var bj=function(a,b,c){
this.matcher_=a;
this.selectionHandler_=c;
this.renderer_=b;
Y(b,["hilite","select","canceldismiss","dismiss"],this);
this.token_=j;
this.rows_=[];
this.hiliteId_=-1;
this.firstRowId_=0;
this.dismissTimer_=this.target_=j
};
U(bj,uh);
Q=bj[y];
Q.maxMatches_=10;
Q.autoHilite_=i;
Q.allowFreeSelect_=k;
Q.wrap_=k;
Q.triggerSuggestionsOnUpdate_=k;
Q.getRenderer=function(){
return this.renderer_
};
La(Q,function(a){
if(a[I]==this.renderer_)switch(a[Zc]){
case "hilite":this.hiliteId(a.row);
    break;
case "select":this.selectHilited();
    break;
case "canceldismiss":this.cancelDelayedDismiss();
    break;
case "dismiss":this.dismissOnDelay()
}
}
);
Q.setToken=function(a,b){
if(this.token_!=a){
    this.token_=a;
    this.matcher_.requestMatchingRows(this.token_,this.maxMatches_,T(this.matchListener_,this),b);
    this.cancelDelayedDismiss()
}
};
Q.getTarget=function(){
return this.target_
};
Q.setTarget=function(a){
this.target_=a
};
Q.isOpen=function(){
return this.renderer_.isVisible()
};
Q.hiliteNext=function(){
var a=this.firstRowId_+this.rows_[x]-1;
if(this.hiliteId_>=this.firstRowId_&&this.hiliteId_<a){
    this.hiliteId(this.hiliteId_+1);
    return i
}
else if(this.hiliteId_==-1){
    this.hiliteId(this.firstRowId_);
    return i
}
else if(this.hiliteId_==a)if(this.allowFreeSelect_){
    this.hiliteId(-1);
    return k
}
else if(this.wrap_){
    this.hiliteId(this.firstRowId_);
    return i
}
return k
};
Q.hilitePrev=function(){
if(this.hiliteId_>this.firstRowId_){
    this.hiliteId(this.hiliteId_-1);
    return i
}
else if(this.allowFreeSelect_&&this.hiliteId_==this.firstRowId_){
    this.hiliteId(-1);
    return k
}
else if(this.wrap_&&(this.hiliteId_==-1||this.hiliteId_==this.firstRowId_)){
    var a=this.firstRowId_+this.rows_[x]-1;
    this.hiliteId(a);
    return i
}
return k
};
Q.hiliteId=function(a){
this.hiliteId_=a;
this.renderer_.hiliteId(a);
return this.getIndexOfId(a)!=-1
};
Q.selectHilited=function(){
var a=this.getIndexOfId(this.hiliteId_);
if(a!=-1){
    a=this.rows_[a];
    var b=this.selectionHandler_.selectRow(a);
    this.dismiss();
    if(!b){
        this[F]({
type:"update",row:a
        }
        );
        this.triggerSuggestionsOnUpdate_&&this.selectionHandler_.update(i)
    }
    return i
}
else{
    this.dismiss();
    this[F]({
type:"update",row:j
    }
    );
    return k
}
};
Q.dismiss=function(){
this.hiliteId_=-1;
this.token_=j;
this.firstRowId_+=this.rows_[x];
this.rows_=[];
p[qb](this.dismissTimer_);
this.dismissTimer_=j;
this.renderer_.dismiss()
};
Q.dismissOnDelay=function(){
if(!this.dismissTimer_)this.dismissTimer_=p[yb](T(this.dismiss,this),100)
};
Q.cancelDelayedDismiss=function(){
p[yb](T(function(){
    if(this.dismissTimer_){
        p[qb](this.dismissTimer_);
        this.dismissTimer_=j
    }
}
,this),10)
};
Q.disposeInternal=function(){
bj.superClass_.disposeInternal[J](this);
this.renderer_.dispose();
this.selectionHandler_.dispose();
this.matcher_=j
};
Q.matchListener_=function(a,b,c){
this.token_==a&&this.renderRows(b,c)
};
Q.renderRows=function(a,b){
var c=b?this.getIndexOfId(this.hiliteId_):j;
this.firstRowId_+=this.rows_[x];
this.rows_=a;
for(var e=[],f=0;
f<a[x];
++f)e[w]({
id:this.getIdOfIndex_(f),data:a[f]
}
);
this.renderer_.renderRows(e,this.token_,this.target_);
if(this.autoHilite_&&e[x]!=0&&this.token_){
    c=c!=j?this.getIdOfIndex_(c):this.firstRowId_;
    this.hiliteId(c)
}
else this.hiliteId_=-1
};
Q.getIndexOfId=function(a){
a=a-this.firstRowId_;
if(a<0||a>=this.rows_[x])return-1;
return a
};
Q.getIdOfIndex_=function(a){
return this.firstRowId_+a
};
Q.attachInputs=function(){
var a=this.selectionHandler_;
a.attachInputs[$c](a,arguments)
};
Q.detachInputs=function(){
var a=this.selectionHandler_;
a.detachInputs[$c](a,arguments)
};
var cj,dj=function(a,b){
if(mg||cj){
    a[Pc]("role",b);
    a.roleName=b
}
}
,ej=function(a,b,c){
if(mg||cj)a[Pc]("aria-"+b,c)
};
var hj=function(a){
a:{
    a=a;
    var b=0,c=0;
    if(fj(a)){
        b=a.selectionStart;
        c=-1
    }
    else if(X){
        var e=gj(a),f=e[0];
        e=e[1];
        if(f.inRange(e)){
            f.setEndPoint("EndToStart",e);
            if(a[Zc]=="textarea"){
                a=f;
                e.duplicate();
                c=b=a[sb];
                for(f=k;
                !f;
                )if(a.compareEndPoints("StartToEnd",a)==0)f=i;
                else{
                    a.moveEnd("character",-1);
                    if(a[sb]==b)c+="\r\n";
                    else f=i
                }
                a=[c[x],-1];
                break a
            }
            b=f[sb][x];
            c=-1
        }
    }
    a=[b,c]
}
return a[0]
}
,gj=function(a){
var b=a[fc]||a[Ab],c=b.selection.createRange();
if(a[Zc]=="textarea"){
    b=b[dc].createTextRange();
    b.moveToElementText(a)
}
else b=
a.createTextRange();
return[b,c]
}
,ij=function(a,b){
if(a[Zc]=="textarea"){
    var c=a[D][Sc](0,b);
    b=ie(c)[x]
}
return b
}
,fj=function(a){
try{
    return typeof a.selectionStart=="number"
}
catch(b){
    return k
}
};
var jj=function(a){
this.handler_=a
};
U(jj,Hg);
var kj=new Mg(0,100);
Q=jj[y];
Q.listen=function(a,b,c,e,f){
if(Md(b))for(var g=0;
g<b[x];
g++)this.listen(a,b[g],c,e,f);
else{
    a=Y(a,b,c||this,e||k,f||this.handler_||this);
    this.recordListenerKey_(a)
}
return this
};
Q.recordListenerKey_=function(a){
if(this.keys_)this.keys_[a]=i;
else if(this.key_){
    this.keys_=kj.getObject();
    this.keys_[this.key_]=i;
    this.key_=j;
    this.keys_[a]=i
}
else this.key_=a
};
Q.unlisten=function(a,b,c,e,f){
if(this.key_||this.keys_)if(Md(b))for(var g=0;
g<b[x];
g++)this.unlisten(a,b[g],c,e,f);
else{
a:{
        c=c||this;
        f=f||this.handler_||this;
        e=!!e;
        if(a=mh(a,b,e))for(b=0;
        b<a[x];
        b++)if(a[b].listener==c&&a[b].capture==e&&a[b].handler==f){
            a=a[b];
            break a
        }
        a=j
    }
    if(a){
        a=a.key;
        nh(a);
        if(this.keys_)hf(this.keys_,a);
        else if(this.key_==a)this.key_=j
    }
}
return this
};
Q.removeAll=function(){
if(this.keys_){
    for(var a in this.keys_){
        nh(a);
        delete this.keys_[a]
    }
    kj.releaseObject(this.keys_);
    this.keys_=j
}
else this.key_&&nh(this.key_)
};
Q.disposeInternal=function(){
jj.superClass_.disposeInternal[J](this);
this.removeAll()
};
La(Q,function(){
d(l("EventHandler.handleEvent not implemented"))
}
);
var mj=function(a,b,c,e,f){
if(!X&&!(ng&&Dg("525")))return i;
if(sg&&f)return lj(a);
if(f&&!e)return k;
if(!c&&(b==17||b==18))return k;
if(X&&e&&b==a)return k;
switch(a){
case 13:return i;
case 27:return!ng
}
return lj(a)
}
,lj=function(a){
if(a>=48&&a<=57)return i;
if(a>=96&&a<=106)return i;
if(a>=65&&a<=90)return i;
if(ng&&a==0)return i;
switch(a){
case 32:case 63:case 107:case 109:case 110:case 111:case 186:case 189:case 187:case 188:case 190:case 191:case 192:case 222:case 219:case 220:case 221:return i;
default:return k
}
};
var nj=function(a,b){
a&&this.attach(a,b)
};
U(nj,uh);
Q=nj[y];
Q.element_=j;
Q.keyPressKey_=j;
Q.keyDownKey_=j;
Q.keyUpKey_=j;
Q.lastKey_=-1;
Q.keyCode_=-1;
var oj={
"3":13,"12":144,"63232":38,"63233":40,"63234":37,"63235":39,"63236":112,"63237":113,"63238":114,"63239":115,"63240":116,"63241":117,"63242":118,"63243":119,"63244":120,"63245":121,"63246":122,"63247":123,"63248":44,"63272":46,"63273":36,"63275":35,"63276":33,"63277":34,"63289":144,"63302":45
}
,pj={
Up:38,Down:40,Left:37,Right:39,Enter:13,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,"U+007F":46,Home:36,End:35,PageUp:33,PageDown:34,Insert:45
}
,qj={
61:187,
59:186
}
,rj=X||ng&&Dg("525");
Q=nj[y];
Q.handleKeyDown_=function(a){
if(ng&&(this.lastKey_==17&&!a[Db]||this.lastKey_==18&&!a[fb]))this.keyCode_=this.lastKey_=-1;
if(rj&&!mj(a[Dc],this.lastKey_,a[cd],a[Db],a[fb]))this[M](a);
else this.keyCode_=mg&&a[Dc]in qj?qj[a[Dc]]:a[Dc]
};
Q.handleKeyup_=function(){
this.keyCode_=this.lastKey_=-1
};
La(Q,function(a){
var b=a.getBrowserEvent(),c,e;
if(X&&a[Zc]=="keypress"){
    c=this.keyCode_;
    e=c!=13&&c!=27?b[Dc]:0
}
else if(ng&&a[Zc]=="keypress"){
    c=this.keyCode_;
    e=b[uc]>=0&&b[uc]<63232&&lj(c)?b[uc]:0
}
else if(lg){
    c=this.keyCode_;
    e=lj(c)?b[Dc]:0
}
else{
    c=b[Dc]||this.keyCode_;
    e=b[uc]||0;
    if(sg&&e==63&&!c)c=191
}
var f=c,g=b.keyIdentifier;
if(c)if(c>=63232&&c in oj)f=oj[c];
else{
    if(c==25&&a[cd])f=9
}
else if(g&&g in pj)f=pj[g];
a=f==this.lastKey_;
this.lastKey_=f;
b=new sj(f,e,a,b);
try{
    this[F](b)
}
finally{
    b.dispose()
}
}
);
Q.getElement=function(){
return this.element_
};
Q.attach=function(a,b){
this.keyUpKey_&&this[Xc]();
this.element_=a;
this.keyPressKey_=Y(this.element_,"keypress",this,b);
this.keyDownKey_=Y(this.element_,"keydown",this.handleKeyDown_,b,this);
this.keyUpKey_=Y(this.element_,"keyup",this.handleKeyup_,b,this)
};
Q.detach=function(){
if(this.keyPressKey_){
    nh(this.keyPressKey_);
    nh(this.keyDownKey_);
    nh(this.keyUpKey_);
    this.keyUpKey_=this.keyDownKey_=this.keyPressKey_=j
}
this.element_=j;
this.keyCode_=this.lastKey_=-1
};
Q.disposeInternal=function(){
nj.superClass_.disposeInternal[J](this);
this[Xc]()
};
var sj=function(a,b,c,e){
e&&this.init(e,void 0);
Oa(this,"key");
Ka(this,a);
this.charCode=b;
this.repeat=c
};
U(sj,Kg);
var tj=function(a,b,c,e){
e=e||150;
this.setSeparators(a!=j?a:",;
");
this.literals_=b||"";
this.preventDefaultOnTab_=this.multi_=c!=j?c:i;
this.timer_=e>0?new Bh(e):j;
this.eh_=new jj(this);
this.activateHandler_=new jj(this);
this.keyHandler_=new nj;
this.lastKeyCode_=-1
};
U(tj,Hg);
Q=tj[y];
Q.whitespaceWrapEntries_=i;
Q.generateNewTokenOnLiteral_=i;
Q.upsideDown_=k;
Q.separatorUpdates_=i;
Q.separatorSelects_=i;
Q.activeElement_=j;
Q.lastValue_="";
Q.waitingForIme_=k;
Q.rowJustSelected_=k;
Q.updateDuringTyping_=i;
Q.attachAutoComplete=function(a){
this.ac_=a
};
Q.getValue=function(){
return this.activeElement_[D]
};
Q.setValue=function(a){
za(this.activeElement_,a)
};
Q.getCursorPosition=function(){
return hj(this.activeElement_)
};
Q.setCursorPosition=function(a){
var b=this.activeElement_,c=a;
if(fj(b))b.selectionStart=c;
else if(X){
    var e=gj(b),f=e[0];
    e=e[1];
    if(f.inRange(e)){
        c=ij(b,c);
        f.collapse(i);
        f.move("character",c);
        f.select()
    }
}
b=this.activeElement_;
a=a;
if(fj(b))b.selectionEnd=a;
else if(X){
    f=gj(b);
    c=f[0];
    f=f[1];
    if(c.inRange(f)){
        a=ij(b,a);
        b=ij(b,hj(b));
        f.collapse(i);
        f.moveEnd("character",a-b);
        f.select()
    }
}
};
Q.attachInput=function(a){
ej(a,"haspopup",i);
this.eh_.listen(a,"focus",this.handleFocus);
this.eh_.listen(a,"blur",this.handleBlur);
this.activeElement_||this.activateHandler_.listen(a,"keydown",this.onKeyDownOnInactiveElement_)
};
Q.detachInput=function(a){
a==this.activeElement_&&this.handleBlur();
this.eh_.unlisten(a,"focus",this.handleFocus);
this.eh_.unlisten(a,"blur",this.handleBlur);
this.activeElement_||this.activateHandler_.unlisten(a,"keydown",this.onKeyDownOnInactiveElement_)
};
Q.attachInputs=function(){
for(var a=0;
a<arguments[x];
a++)this.attachInput(arguments[a])
};
Q.detachInputs=function(){
for(var a=0;
a<arguments[x];
a++)this.detachInput(arguments[a])
};
Q.selectRow=function(a,b){
this.setTokenText(a[db](),b);
return k
};
Q.setTokenText=function(a,b){
if(b!==ba?b:this.multi_){
    var c=this.getTokenIndex_(this.getValue(),this.getCursorPosition()),e=this.splitInput_(this.getValue()),f=a;
    this.separatorCheck_[lb](f)||(f=f[B](/[\s\xa0]+$/,"")+this.defaultSeparator_);
    if(this.whitespaceWrapEntries_){
        if(c!=0&&!ee(e[c-1]))f=" "+f;
        if(c==e[x]-1)f+=" "
    }
    if(f!=e[c]){
        e[c]=f;
        f=this.activeElement_;
        mg&&f[Mb]();
        za(f,e[ud](""));
        for(var g=0,h=0;
        h<=c;
        h++)g+=e[h][x];
        f[zc]();
        this.setCursorPosition(g)
    }
}
else this.setValue(a);
this.rowJustSelected_=
i
};
Q.disposeInternal=function(){
tj.superClass_.disposeInternal[J](this);
this.eh_.dispose();
delete this.eh_;
this.activateHandler_.dispose();
this.activateHandler_=j
};
Q.setSeparators=function(a){
this.separators_=a;
this.defaultSeparator_=this.separators_[Sc](0,1);
a=this.multi_?"[\\s"+this.separators_+"]+":"[\\s]+";
this.trimmer_=la("^"+a+"|"+a+"$","g");
this.separatorCheck_=la("\\s*["+this.separators_+"]$")
};
Q.setUpsideDown=function(a){
this.upsideDown_=a
};
Q.handleKeyEvent=function(a){
switch(a[Dc]){
case 40:if(this.ac_[qc]()){
        this.moveDown_();
        a[Sb]();
        return i
    }
    else if(!this.multi_){
        this.update(i);
        a[Sb]();
        return i
    }
    break;
case 38:if(this.ac_[qc]()){
        this.moveUp_();
        a[Sb]();
        return i
    }
    break;
case 9:if(this.ac_[qc]()&&!a[cd]){
        this.update();
        if(this.ac_.selectHilited()&&this.preventDefaultOnTab_){
            a[Sb]();
            return i
        }
    }
    else this.ac_.dismiss();
    break;
case 13:if(this.ac_[qc]()){
        this.update();
        if(this.ac_.selectHilited()){
            a[Sb]();
            a[Ob]();
            return i
        }
    }
    else this.ac_.dismiss();
    break;
case 27:if(this.ac_[qc]()){
        this.ac_.dismiss();
        a[Sb]();
        a[Ob]();
        return i
    }
    break;
case 229:if(!this.waitingForIme_){
        this.startWaitingForIme_();
        return i
    }
    break;
default:if(this.timer_&&!this.updateDuringTyping_){
        this.timer_[cb]();
        this.timer_[xc]()
    }
}
return this.handleSeparator_(a)
};
Q.handleSeparator_=function(a){
var b=this.multi_&&a[uc]&&this.separators_[E](m.fromCharCode(a[uc]))!=-1;
this.separatorUpdates_&&b&&this.update();
if(this.separatorSelects_&&b)if(this.ac_.selectHilited()){
    a[Sb]();
    return i
}
return k
};
Q.needKeyUpListener=function(){
return k
};
Q.handleKeyUp=function(){
return k
};
Q.addKeyEvents_=function(){
this.keyHandler_.attach(this.activeElement_);
this.eh_.listen(this.keyHandler_,"key",this.onKey_);
this.needKeyUpListener()&&this.eh_.listen(this.activeElement_,"keyup",this.handleKeyUp);
X&&this.eh_.listen(this.activeElement_,"keypress",this.onIeKeyPress_)
};
Q.removeKeyEvents_=function(){
this.eh_.unlisten(this.keyHandler_,"key",this.onKey_);
this.keyHandler_[Xc]();
this.eh_.unlisten(this.activeElement_,"keyup",this.handleKeyUp);
X&&this.eh_.unlisten(this.activeElement_,"keypress",this.onIeKeyPress_);
this.waitingForIme_&&this.stopWaitingForIme_()
};
Q.handleFocus=function(a){
this.activateHandler_.removeAll();
this.ac_&&this.ac_.cancelDelayedDismiss();
if(a[I]!=this.activeElement_){
    this.activeElement_=a[I]||j;
    if(this.timer_){
        this.timer_[xc]();
        this.eh_.listen(this.timer_,"tick",this.onTick_)
    }
    this.lastValue_=this.getValue();
    this.addKeyEvents_()
}
};
Q.handleBlur=function(){
if(this.activeElement_){
    this.removeKeyEvents_();
    this.activeElement_=j;
    if(this.timer_){
        this.timer_[cb]();
        this.eh_.unlisten(this.timer_,"tick",this.onTick_)
    }
    this.ac_&&this.ac_.dismissOnDelay()
}
};
Q.onTick_=function(){
this.update()
};
Q.onKeyDownOnInactiveElement_=function(a){
this.handleFocus(a)
};
Q.onKey_=function(a){
this.lastKeyCode_=a[Dc];
this.ac_&&this.handleKeyEvent(a)
};
Q.onKeyPress_=function(){
this.waitingForIme_&&this.lastKeyCode_!=229&&this.stopWaitingForIme_()
};
Q.onKeyUp_=function(a){
if(this.waitingForIme_&&(a[Dc]==13||a[Dc]==77&&a[Db]))this.stopWaitingForIme_()
};
Q.startWaitingForIme_=function(){
if(!this.waitingForIme_){
    this.eh_.listen(this.activeElement_,"keyup",this.onKeyUp_);
    this.eh_.listen(this.activeElement_,"keypress",this.onKeyPress_);
    this.waitingForIme_=i
}
};
Q.stopWaitingForIme_=function(){
if(this.waitingForIme_){
    this.waitingForIme_=k;
    this.eh_.unlisten(this.activeElement_,"keypress",this.onKeyPress_);
    this.eh_.unlisten(this.activeElement_,"keyup",this.onKeyUp_)
}
};
Q.onIeKeyPress_=function(a){
this.handleSeparator_(a)
};
Q.update=function(a){
if(a||this.activeElement_&&this.getValue()!=this.lastValue_){
    if(a||!this.rowJustSelected_){
        a=this.parseToken();
        if(this.ac_){
            this.ac_.setTarget(this.activeElement_);
            this.ac_.setToken(a,this.getValue())
        }
    }
    this.lastValue_=this.getValue()
}
this.rowJustSelected_=k
};
Q.parseToken=function(){
return this.parseToken_()
};
Q.moveUp_=function(){
return this.upsideDown_?this.ac_.hiliteNext():this.ac_.hilitePrev()
};
Q.moveDown_=function(){
return this.upsideDown_?this.ac_.hilitePrev():this.ac_.hiliteNext()
};
Q.parseToken_=function(){
var a=this.getCursorPosition(),b=this.getValue();
return this.trim_(this.splitInput_(b)[this.getTokenIndex_(b,a)])
};
Q.trim_=function(a){
return this.trimmer_?m(a)[B](this.trimmer_,""):a
};
Q.getTokenIndex_=function(a,b){
var c=this.splitInput_(a);
if(b==a[x])return c[x]-1;
for(var e=0,f=0,g=0;
f<c[x]&&g<b;
f++){
    g+=c[f][x];
    e=f
}
return e
};
Q.splitInput_=function(a){
if(!this.multi_)return[a];
a=m(a)[Fb]("");
for(var b=[],c=[],e=0,f=k;
e<a[x];
e++)if(this.literals_&&this.literals_[E](a[e])!=-1){
    if(this.generateNewTokenOnLiteral_&&!f){
        b[w](c[ud](""));
        pa(c,0)
    }
    c[w](a[e]);
    f=!f
}
else if(!f&&this.separators_[E](a[e])!=-1){
    c[w](a[e]);
    b[w](c[ud](""));
    pa(c,0)
}
else c[w](a[e]);
b[w](c[ud](""));
return b
};
var uj=function(a,b,c,e){
this.top=a;
this.right=b;
this.bottom=c;
Da(this,e)
};
uj[y].clone=function(){
return new uj(this.top,this[Fd],this[Nc],this[ec])
};
na(uj[y],function(){
return"("+this.top+"t, "+this[Fd]+"r, "+this[Nc]+"b, "+this[ec]+"l)"
}
);
Pa(uj[y],function(a){
a=!this||!a?k:a instanceof uj?a[ec]>=this[ec]&&a[Fd]<=this[Fd]&&a.top>=this.top&&a[Nc]<=this[Nc]:a.x>=this[ec]&&a.x<=this[Fd]&&a.y>=this.top&&a.y<=this[Nc];
return a
}
);
uj[y].expand=function(a,b,c,e){
if(Rd(a)){
    this.top-=a.top;
    this.right+=a[Fd];
    this.bottom+=a[Nc];
    this.left-=a[ec]
}
else{
    this.top-=a;
    this.right+=b;
    this.bottom+=c;
    this.left-=e
}
return this
};
var vj=function(a,b,c,e){
Da(this,a);
this.top=b;
ta(this,c);
Xa(this,e)
};
vj[y].clone=function(){
return new vj(this[ec],this.top,this[z],this[P])
};
na(vj[y],function(){
return"("+this[ec]+", "+this.top+" - "+this[z]+"w x "+this[P]+"h)"
}
);
vj[y].intersection=function(a){
var b=r.max(this[ec],a[ec]),c=r.min(this[ec]+this[z],a[ec]+a[z]);
if(b<=c){
    var e=r.max(this.top,a.top);
    a=r.min(this.top+this[P],a.top+a[P]);
    if(e<=a){
        Da(this,b);
        this.top=e;
        ta(this,c-b);
        Xa(this,a-e);
        return i
    }
}
return k
};
Pa(vj[y],function(a){
return a instanceof vj?this[ec]<=a[ec]&&this[ec]+this[z]>=a[ec]+a[z]&&this.top<=a.top&&this.top+this[P]>=a.top+a[P]:a.x>=this[ec]&&a.x<=this[ec]+this[z]&&a.y>=this.top&&a.y<=this.top+this[P]
}
);
var xj=function(a,b,c){
Od(b)?wj(a,c,b):df(b,Zd(wj,a))
}
,wj=function(a,b,c){
a[H][yj(c)]=b
}
,zj=function(a,b){
var c=xi(a);
if(c[fd]&&c[fd][$b])if(c=c[fd][$b](a,j))return c[b]||c.getPropertyValue(b);
return""
}
,Aj=function(a,b){
return zj(a,b)||(a[Qc]?a[Qc][b]:j)||a[H][b]
}
,Bj=function(a){
return Aj(a,"position")
}
,Dj=function(a,b,c){
var e,f=mg&&(sg||tg)&&Dg("1.9");
if(b instanceof ki){
    e=b.x;
    b=b.y
}
else{
    e=b;
    b=c
}
Da(a[H],Cj(e,f));
a[H].top=Cj(b,f)
}
,Ej=function(a){
a=a?a[zb]==9?a:xi(a):q;
if(X&&!yi(a).isCss1CompatMode())return a[dc];
return a[Dd]
}
,Fj=function(a){
var b=a[jb]();
if(X){
    a=a[fc];
    b.left-=a[Dd][Kc]+a[dc][Kc];
    b.top-=a[Dd][Tc]+a[dc][Tc]
}
return b
}
,Gj=function(a){
if(X)return a.offsetParent;
var b=xi(a),c=Aj(a,"position"),e=c=="fixed"||c=="absolute";
for(a=a[O];
a&&a!=b;
a=a[O]){
    c=Aj(a,"position");
    e=e&&c=="static"&&a!=b[Dd]&&a!=b[dc];
    if(!e&&(a.scrollWidth>a[tb]||a[Cc]>a[Hc]||c=="fixed"||c=="absolute"))return a
}
return j
}
,Jj=function(a){
var b=new uj(0,aa,aa,0),c=yi(a),e=c.getDocument()[dc],f=c.getDocumentScrollElement(),g;
for(a=
a;
a=Gj(a);
)if((!X||a[tb]!=0)&&(!ng||a[Hc]!=0||a!=e)&&(a.scrollWidth!=a[tb]||a[Cc]!=a[Hc])&&Aj(a,"overflow")!="visible"){
    var h=Hj(a),n;
    n=a;
    if(mg&&!Dg("1.9")){
        var o=ea(zj(n,"borderLeftWidth"));
        if(Ij(n)){
            var s=n[Jb]-n[tb]-o-ea(zj(n,"borderRightWidth"));
            o+=s
        }
        n=new ki(o,ea(zj(n,"borderTopWidth")))
    }
    else n=new ki(n[Kc],n[Tc]);
    h.x+=n.x;
    h.y+=n.y;
    b.top=r.max(b.top,h.y);
    b.right=r.min(b[Fd],h.x+a[tb]);
    b.bottom=r.min(b[Nc],h.y+a[Hc]);
    Da(b,r.max(b[ec],h.x));
    g=g||a!=f
}
e=f[Ic];
f=f[bb];
if(ng){
    b.left+=e;
    b.top+=f
}
else{
    Da(b,
    r.max(b[ec],e));
    b.top=r.max(b.top,f)
}
if(!g||ng){
    b.right+=e;
    b.bottom+=f
}
c=c.getViewportSize();
b.right=r.min(b[Fd],e+c[z]);
b.bottom=r.min(b[Nc],f+c[P]);
return b.top>=0&&b[ec]>=0&&b[Nc]>b.top&&b[Fd]>b[ec]?b:j
}
,Hj=function(a){
var b,c=xi(a),e=Aj(a,"position"),f=mg&&c[oc]&&!a[jb]&&e=="absolute"&&(b=c[oc](a))&&(b[jc]<0||b[kc]<0),g=new ki(0,0),h=Ej(c);
if(a==h)return g;
if(a[jb]){
    b=Fj(a);
    a=yi(c).getDocumentScroll();
    g.x=b[ec]+a.x;
    g.y=b.top+a.y
}
else if(c[oc]&&!f){
    b=c[oc](a);
    a=c[oc](h);
    g.x=b[jc]-a[jc];
    g.y=b[kc]-
    a[kc]
}
else{
    b=a;
    do{
        g.x+=b.offsetLeft;
        g.y+=b[nd];
        if(b!=a){
            g.x+=b[Kc]||0;
            g.y+=b[Tc]||0
        }
        if(ng&&Bj(b)=="fixed"){
            g.x+=c[dc][Ic];
            g.y+=c[dc][bb];
            break
        }
        b=b.offsetParent
    }
    while(b&&b!=a);
    if(lg||ng&&e=="absolute")g.y-=c[dc][nd];
    for(b=a;
    (b=Gj(b))&&b!=c[dc]&&b!=h;
    ){
        g.x-=b[Ic];
        if(!lg||b[dd]!="TR")g.y-=b[bb]
    }
}
return g
}
,Kj=function(a,b,c){
var e=Hj(a);
if(b instanceof ki){
    c=b.y;
    b=b.x
}
b=b-e.x;
c=c-e.y;
Dj(a,a.offsetLeft+b,a[nd]+c)
}
,Lj=function(a,b,c){
if(b instanceof mi){
    c=b[P];
    b=b[z]
}
else{
    if(c==ba)d(l("missing height argument"));
    c=c
}
ta(a[H],Cj(b,i));
Xa(a[H],Cj(c,i))
}
,Cj=function(a,b){
if(typeof a=="number")a=(b?r[ub](a):a)+"px";
return a
}
,Mj=function(a){
var b=lg&&!Dg("10");
if(Aj(a,"display")!="none")return b?new mi(a[Jb]||a[tb],a[td]||a[Hc]):new mi(a[Jb],a[td]);
var c=a[H],e=c[ld],f=c.visibility,g=c.position;
$a(c,"hidden");
ra(c,"absolute");
Wa(c,"inline");
if(b){
    b=a[Jb]||a[tb];
    a=a[td]||a[Hc]
}
else{
    b=a[Jb];
    a=a[td]
}
Wa(c,e);
ra(c,g);
$a(c,f);
return new mi(b,a)
}
,Nj=function(a){
var b=Hj(a);
a=Mj(a);
return new vj(b.x,b.y,a[z],a[P])
}
,Oj=
{
}
,yj=function(a){
return Oj[a]||(Oj[a]=m(a)[B](/\-([a-z])/g,function(b,c){
    return c[qd]()
}
))
}
,Pj=function(a,b){
var c=a[H];
if("opacity"in c)c.opacity=b;
else if("MozOpacity"in c)c.MozOpacity=b;
else if("filter"in c)c.filter=b===""?"":"alpha(opacity="+b*100+")"
}
,Qj=function(a,b){
Wa(a[H],b?"":"none")
}
,Ij=function(a){
return"rtl"==Aj(a,"direction")
}
,Rj=mg?"MozUserSelect":ng?"WebkitUserSelect":j,Sj=function(a,b,c){
c=!c?a[xd]("*"):j;
if(Rj){
    b=b?"none":"";
    a[H][Rj]=b;
    if(c){
        a=0;
        for(var e;
        e=c[a];
        a++)e[H][Rj]=b
    }
}
else if(X||
        lg){
    b=b?"on":"";
    a[Pc]("unselectable",b);
    if(c)for(a=0;
    e=c[a];
    a++)e[Pc]("unselectable",b)
}
}
,Tj={
thin:2,medium:4,thick:6
}
,Uj=function(a,b){
if((a[Qc]?a[Qc][b+"Style"]:j)=="none")return 0;
var c=a[Qc]?a[Qc][b+"Width"]:j;
if(c in Tj)return Tj[c];
var e;
e=a;
var f=c;
c="left";
if(/^\d+px?$/[lb](f))e=da(f,10);
else{
    var g=e[H][c],h=e.runtimeStyle[c];
    e.runtimeStyle[c]=e[Qc][c];
    e[H][c]=f;
    f=e[H].pixelLeft;
    e[H][c]=g;
    e.runtimeStyle[c]=h;
    e=f
}
return e
};
var Vj=function(){
};
Kd(Vj);
Vj[y].nextId_=0;
Vj[y].getNextUniqueId=function(){
return":"+(this.nextId_++)[db](36)
};
Vj.getInstance();
var Wj=function(a,b,c,e){
this.parent_=a||q[dc];
this.dom_=yi(this.parent_);
this.reposition_=!a;
this.element_=j;
this.token_="";
this.rows_=[];
this.startRenderingRows_=this.hilitedRow_=-1;
this.visible_=k;
t(this,"ac-renderer");
this.rowClassName="ac-row";
this.legacyActiveClassName_="active";
this.activeClassName="ac-active";
this.highlightedClassName="ac-highlighted";
this.customRenderer_=b||j;
this.useStandardHighlighting_=e!=j?e:i;
this.highlightAllTokens_=k;
this.rightAlign_=c!=j?c:k;
this.keepAligned_=j;
this.topAlign_=
k
};
U(Wj,uh);
Q=Wj[y];
Q.getElement=function(){
return this.element_
};
Q.setTopAlign=function(a){
this.topAlign_=a
};
Q.renderRows=function(a,b,c){
this.token_=b;
this.rows_=a;
this.hilitedRow_=-1;
this.startRenderingRows_=$d();
this.target_=c;
this.rowDivs_=[];
this.redraw()
};
Q.dismiss=function(){
this.target_&&ej(this.target_,"activedescendant","");
if(this.visible_){
    this.visible_=k;
    Qj(this.element_,k)
}
};
Q.show=function(){
if(!this.visible_){
    this.visible_=i;
    Qj(this.element_,i)
}
};
Q.isVisible=function(){
return this.visible_
};
Q.hiliteRow=function(a){
this.hiliteNone();
this.hilitedRow_=a;
if(a>=0&&a<this.element_[bd][x]){
    a=this.rowDivs_[a];
    ui(a,this.activeClassName,this.legacyActiveClassName_);
    if(this.target_)ej(this.target_,"activedescendant",a?a.id:"");
    var b=a;
    a=this.element_;
    var c=Hj(b),e=Hj(a),f;
    var g=a;
    if(X){
        var h=Uj(g,"borderLeft");
        f=Uj(g,"borderRight");
        var n=Uj(g,"borderTop");
        g=Uj(g,"borderBottom");
        f=new uj(n,f,g,h)
    }
    else{
        h=zj(g,"borderLeftWidth");
        f=zj(g,"borderRightWidth");
        n=zj(g,"borderTopWidth");
        g=zj(g,"borderBottomWidth");
        f=new uj(ea(n),ea(f),ea(g),ea(h))
    }
    h=c.x-e.x-f[ec];
    c=c.y-e.y-f.top;
    e=a[tb]-b[Jb];
    b=a[Hc]-b[td];
    a.scrollLeft+=r.min(h,r.max(h-e,0));
    a.scrollTop+=r.min(c,r.max(c-b,0))
}
};
Q.hiliteNone=function(){
this.hilitedRow_>=0&&vi(this.rowDivs_[this.hilitedRow_],this.activeClassName,this.legacyActiveClassName_)
};
Q.hiliteId=function(a){
if(a==-1)this.hiliteRow(-1);
else for(var b=0;
b<this.rows_[x];
b++)if(this.rows_[b].id==a){
    this.hiliteRow(b);
    break
}
};
Q.setMenuClasses_=function(a){
ui(a,this[ob])
};
Q.maybeCreateElement_=function(){
if(!this.element_){
    var a=this.dom_.createDom("div",{
style:"display:none"
    }
    );
    this.element_=a;
    this.setMenuClasses_(a);
    dj(a,"listbox");
    a.id=Vj.getInstance().getNextUniqueId();
    if(this.target_){
        dj(this.target_,"combobox");
        ej(this.target_,"autocomplete","list");
        ej(this.target_,"haspopup",i)
    }
    this.dom_[v](this.parent_,a);
    Y(a,"click",this.handleClick_,k,this);
    Y(a,"mousedown",this.handleMouseDown_,k,this);
    Y(this.dom_.getDocument(),"click",this.handleDocumentClick_,k,this);
    Y(a,
    "mouseover",this.handleMouseOver_,k,this)
}
};
Q.redraw=function(){
this.maybeCreateElement_();
if(this.topAlign_)$a(this.element_[H],"hidden");
pa(this.rowDivs_,0);
this.dom_.removeChildren(this.element_);
if(this.customRenderer_&&this.customRenderer_.render)this.customRenderer_.render(this,this.element_,this.rows_,this.token_);
else{
    var a=j;
    cf(this.rows_,function(b){
        b=this.renderRowHtml(b,this.token_);
        this.topAlign_?this.element_[Ub](b,a):this.dom_[v](this.element_,b);
        a=b
    }
    ,this)
}
if(this.rows_[x]==0)this.dismiss();
else{
    this.show();
    this.preventMacScrollbarResurface_(this.element_);
    this.reposition();
    Sj(this.element_,i)
}
};
Q.reposition=function(){
if(this.target_&&this.reposition_){
    var a=Hj(this.target_),b=Mj(this.target_),c=Mj(Ej(this.target_)),e=Mj(this.element_);
    a.y=this.topAlign_?a.y-e[P]:a.y+b[P];
    if((this.rightAlign_||a.x+e[z]>c[z])&&this.keepAligned_!="LEFT"){
        a.x=a.x+b[z]-e[z];
        this.keepAligned_="RIGHT"
    }
    else this.keepAligned_="LEFT";
    Kj(this.element_,a);
    if(this.topAlign_)$a(this.element_[H],"visible")
}
};
Q.setAutoPosition=function(a){
this.reposition_=a
};
Q.disposeInternal=function(){
Wj.superClass_.disposeInternal[J](this);
if(this.element_){
    lh(this.element_,"click",this.handleClick_,k,this);
    lh(this.element_,"mousedown",this.handleMouseDown_,k,this);
    lh(this.dom_.getDocument(),"click",this.handleDocumentClick_,k,this);
    lh(this.element_,"mouseover",this.handleMouseOver_,k,this);
    this.dom_[Uc](this.element_);
    this.element_=j;
    this.visible_=k
}
delete this.parent_
};
Q.preventMacScrollbarResurface_=function(a){
if(mg&&sg){
    ta(a[H],"");
    Va(a[H],"visible");
    ta(a[H],a[Jb]);
    Va(a[H],"auto")
}
};
Q.renderRowContents_=function(a,b,c){
xa(c,se(a[Bb][db]()))
};
Q.hiliteMatchingText_=function(a,b){
if(a[zb]==3){
    var c=j;
    if(Md(b)&&b[x]>1&&!this.highlightAllTokens_)c=We(b,1);
    var e=this.getTokenRegExp_(b);
    if(e[x]!=0){
        var f=a[yd],g=la("(.*?)(^|\\W+)("+e+")","gi");
        e=[];
        for(var h=0,n=g[rb](f),o=0;
        n;
        ){
            o++;
            e[w](n[1]);
            e[w](n[2]);
            e[w](n[3]);
            h=g.lastIndex;
            n=g[rb](f)
        }
        e[w](f[Sc](h));
        if(e[x]>1){
            c=!this.highlightAllTokens_?1:o;
            for(f=0;
            f<c;
            f++){
                g=3*f;
                a.nodeValue=e[g]+e[g+1];
                h=this.dom_[K]("b");
                t(h,this.highlightedClassName);
                this.dom_[v](h,this.dom_[Nb](e[g+2]));
                h=a[O][Ub](h,
                a[md]);
                a[O][Ub](this.dom_[Nb](""),h[md]);
                a=h[md]
            }
            e=We(e,c*3);
            a.nodeValue=e[ud]("")
        }
        else c&&this.hiliteMatchingText_(a,c)
    }
}
else for(e=a[Ec];
e;
){
    c=e[md];
    this.hiliteMatchingText_(e,b);
    e=c
}
};
Q.getTokenRegExp_=function(a){
var b="";
if(!a)return b;
if(this.highlightAllTokens_)if(Md(a)){
    a=Me(a,function(c){
        return!ge(c)
    }
    );
    a=Ne(a,ze);
    b=a[ud]("|")
}
else{
    b=a[B](/[\s\xa0]+/g," ")[B](/^\s+|\s+$/g,"");
    b=ze(b);
    b=b[B](/ /g,"|")
}
else b=Md(a)?a[x]>0?ze(a[0]):"":ze(a);
return b
};
Q.renderRowHtml=function(a,b){
var c=this.dom_.createDom("div",{
className:this.rowClassName,id:Vj.getInstance().getNextUniqueId()
}
);
dj(c,"option");
this.customRenderer_&&this.customRenderer_.renderRow?this.customRenderer_.renderRow(a,b,c):this.renderRowContents_(a,b,c);
b&&this.useStandardHighlighting_&&this.hiliteMatchingText_(c,b);
ui(c,this.rowClassName);
this.rowDivs_[w](c);
return c
};
Q.getRowFromEventTarget_=function(a){
for(;
a&&a!=this.element_&&!Qe(ti(a),this.rowClassName);
)a=a[O];
return a?Ke(this.rowDivs_,a):-1
};
Q.handleClick_=function(a){
var b=this.getRowFromEventTarget_(a[I]);
b>=0&&this[F]({
type:"select",row:this.rows_[b].id
}
);
a[Ob]()
};
Q.handleMouseDown_=function(a){
this[F]("canceldismiss");
a[Ob]();
a[Sb]()
};
Q.handleDocumentClick_=function(){
this[F]("dismiss")
};
Q.handleMouseOver_=function(a){
a=this.getRowFromEventTarget_(a[I]);
if(a>=0)$d()-this.startRenderingRows_<300||this[F]({
type:"hilite",row:this.rows_[a].id
}
)
};
var Xj=function(){
};
Xj[y].render=function(){
};
Xj[y].renderRow=function(){
};
var Yj={
}
,Zj=function(a,b,c,e){
this.selectEventCallback_=function(){
};
this.tickUserInputCallback_=function(){
};
tj[J](this,a,b,c);
this.lastTokenCopy_=j;
this.unexpandedExplicitGroups_=!!e
};
U(Zj,tj);
Q=Zj[y];
Q.selectRow=function(a){
if(!(a instanceof $j)){
    if(this.unexpandedExplicitGroups_&&a instanceof ak&&a.getItem()[N]){
        var b=a.getItem().id;
        if(b=="^Mine")b="s0";
        a=['"',a.getItem()[N],'" <.',b,".>"][ud]("")
    }
    else if(a.getContacts)a=a.getContacts()[ud](", ");
    this.selectEventCallback_();
    Zj.superClass_.selectRow[J](this,a)
}
};
Q.handleKeyEvent=function(a){
this.tickUserInputCallback_();
tj[y].handleKeyEvent[J](this,a)
};
Q.setEventsCallbacks=function(a,b){
this.selectEventCallback_=a;
this.tickUserInputCallback_=b
};
Q.getLastValue=function(){
return this.lastValue_
};
Q.getLastPrefix=function(){
return this.lastTokenCopy_
};
var ck=function(a,b){
this.findGroups_=a;
this.orderByType_=b;
this.contacts_=[];
this.groups_=new bk([])
};
ck[y].setOrderByType=function(a){
this.orderByType_=a
};
ck[y].setDataSource=function(a,b){
this.contacts_=a;
this.groups_=new bk(b)
};
var dk=function(a,b,c,e){
for(var f=a.members,g=[],h=[],n=[],o=0;
o<f[x];
++o){
    var s=f[o].email;
    c.hasContext&&c.addressHash[s]?h[w](f[o]):g[w](f[o]);
    e[s]&&n[w](f[o])
}
return new ak(a,b,f,g,h,n)
};
ck[y].requestMatchingRows=function(a,b,c){
var e=[];
if(a=="")return[];
if(c){
    for(var f="",g=0;
    g<c[x];
    ++g){
        var h=c[Lb](g);
        if(h==";
"||h==","){
            f=je(f);
            f[x]>0&&e[w](f);
            f=""
        }
        else f+=h
    }
    f=je(f);
    f[x]>0&&e[w](f)
}
return this.findMatchingRows_(a,e,b)
};
ck[y].determineContext_=function(a){
for(var b={
}
,c=0;
c<a[x];
++c){
    var e=a[c],f=e,g=e=j;
    f=je(f);
    if(f=f[nc](ek)){
        e=f[1]||j;
        g=f[2]||j
    }
    if(e&&!g)if(f=e[nc](fk)){
        e="";
        g=f[0]
    }
    if(e){
        e=je(e);
        if(be(e,'"')&&ce(e,'"'))e=e[Ed](1,e[x]-2)
    }
    if(g)g=je(g);
    e={
name:e,email:g
    }
    ;
    if(e.email)b[e.email]=i
}
a={
};
e=[];
g={
};
f=k;
var h=0,n={
}
,o=i;
for(c=0;
c<this.contacts_[x];
++c){
    var s=this.contacts_[c],A=s.email;
    if(b[A]){
        f=g[A]=i;
        h++;
        s=s.groups;
        if(o){
            for(A=0;
            A<s[x];
            ++A){
                var G=s[A];
                a[G.id]=1;
                e[w](G.id)
            }
            o=k
        }
        else for(A=0;
        A<s[x];
        ++A){
            G=
            s[A];
            a[G.id]&&a[G.id]++
        }
    }
}
for(c=0;
c<e[x];
++c){
    b=e[c];
    if(a[b]==h)n[b]=i
}
return{
hasContext:f,groupIdHash:n,addressHash:g
}
};
ck[y].processImplicitGroups_=function(a,b){
for(var c={
}
,e=[],f=0;
f<a[x];
++f){
    var g=a[f].groups;
    if(g)for(var h=0;
    h<g[x];
    ++h){
        var n=g[h].id;
        if(g[h].implicit)if(!(b.hasContext&&!b.groupIdHash[n]))if(n[Lb](0)!="^")if(!c[n]){
            var o=this.groups_.get(n);
            if(o){
                c[n]=i;
                e[w](o)
            }
        }
    }
}
e[Mc](function(s,A){
    return s.affinity>A.affinity?-1:A.affinity>s.affinity?1:0
}
);
return e
};
var gk=function(){
};
gk[y].compound=function(){
var a=arguments,b=function(c,e){
    var f,g;
    for(f=0;
    f<a[x];
    f++){
        g=a[f](c,e);
        if(g!=0)return g
    }
    return 0
};
return b
};
gk[y].byAffinity=function(a,b){
return a.getAffinity()>b.getAffinity()?-1:b.getAffinity()>a.getAffinity()?1:0
};
gk[y].byName=function(a,b){
var c=a.getItem()[N]||"",e=b.getItem()[N]||"";
if(c>e)return 1;
else if(e>c)return-1;
return 0
};
gk[y].byType=function(a,b){
var c=function(e){
    if(e.getType()!=0)return k;
    return!e.getIsDomainContact()
};
if(c(a)&&!c(b))return-1;
if(!c(a)&&c(b))return 1;
if(a.getType()==1&&b.getType()!=1)return-1;
if(a.getType()!=1&&b.getType()==1)return 1;
return 0
};
Q=ck[y];
Q.createEmailsHash_=function(a){
for(var b={
}
,c=0;
c<a[x];
++c)if(a[c].email)b[a[c].email]=i;
return b
};
Q.findMatchingRows_=function(a,b,c){
var e=this.findMatchingContacts_(a),f=[],g=[];
if(this.findGroups_){
    g=this.findMatchingGroups_(a,c);
    var h={
hasContext:k
    }
    ;
    if(b[x]>0)h=this.determineContext_(b);
    b=this.processImplicitGroups_(e,h,c);
    var n=this.createEmailsHash_(e);
    for(a=0;
    a<c&&a<b[x];
    ++a){
        var o=b[a];
        f[w](dk(o,o.affinity,h,n))
    }
}
for(a=0;
a<c&&a<g[x];
++a){
    o=g[a];
    f[w](dk(o,2E7,h,n))
}
for(a=0;
a<c&&a<e[x];
++a){
    g=e[a];
    h=g.affinity;
    if(a==0)h=1E7;
    f[w](new hk(g,h))
}
e=new gk;
g=e.compound(e.byAffinity,e.byName);
f[Mc](g);
f[x]>c&&f[rd](c,f[x]-c);
if(this.orderByType_){
    c=e.compound(e.byType,e.byAffinity,e.byName);
    f[Mc](c)
}
return this.restrictGroupCount_(f)
};
Q.restrictGroupCount_=function(a){
for(var b=0,c=0,e=0;
e<a[x];
e++){
    var f=a[e];
    if(f.getType()==0)b++;
    else f.getType()==1&&c++
}
e=b*2;
e=e>5?e:5;
if(c>e){
    b=b+e;
    a[rd](b,a[x]-b)
}
return a
};
Q.findMatchingGroups_=function(a,b){
var c=ze(a);
c=la('(^|<| |"|\\()'+c,"i");
for(var e=[],f=this.groups_.getOrderedList(),g=0;
g<f[x]&&e[x]<b;
++g){
    var h=f[g];
    h.members[x]>0&&h[N]&&h[N][nc](c)&&e[w](h)
}
return e
};
Q.findMatchingContacts_=function(a){
a=ze(a);
a=la('(^|<| |"|\\()'+a,"i");
for(var b=[],c=this.contacts_,e=0;
e<c[x];
++e){
    var f=c[e],g=f[db]();
    if(a[lb](g))b[w](f);
    else if(f.aliases){
        g=f.aliases;
        for(var h=0;
        h<g[x];
        ++h)if(a[lb](g[h])){
            b[w](f);
            break
        }
    }
}
return b
};
var ik=function(){
};
Q=ik[y];
Q.getNumberOfContacts=function(){
return 0
};
Q.getContacts=function(){
return[]
};
Q.getAllContactNames=function(){
return[]
};
Q.getType=function(){
return this.type_
};
Q.getAffinity=function(){
return this.affinity_
};
Q.getItem=function(){
return this.item_
};
var hk=function(a,b){
this.type_=0;
this.item_=a;
this.affinity_=b
};
U(hk,ik);
hk[y].getNumberOfContacts=function(){
return 1
};
hk[y].getContacts=function(){
return[this.item_[db]()]
};
hk[y].getAllContactNames=function(){
return this.item_[N]?[this.item_[N]]:[]
};
hk[y].getIsDomainContact=function(){
return!!this.item_.isDomainContact
};
var ak=function(a,b,c,e,f,g){
this.type_=1;
this.item_=a;
this.affinity_=b;
this.groupMembers_=c;
this.newMembers_=e;
this.contextMembers_=f;
this.matchedMembers_=g;
this.context_={
};
for(a=0;
a<f[x];
++a)this.context_[f[a].email]=i
};
U(ak,ik);
Q=ak[y];
Q.getNumberOfContacts=function(){
return this.groupMembers_[x]
};
Q.getContacts=function(){
return this.newMembers_
};
Q.getAllContactNames=function(){
for(var a=[],b=0;
b<this.groupMembers_[x];
++b)this.groupMembers_[b][N]&&a[w](this.groupMembers_[b][N]);
return a
};
Q.getContext=function(){
return this.context_
};
Q.getMembers=function(){
return this.groupMembers_
};
Q.getMatchedMembers=function(){
return this.matchedMembers_
};
var $j=function(a){
this.type_=a
};
na($j[y],function(){
return""
}
);
$j[y].getType=function(){
return this.type_
};
var bk=function(a){
this.orderedList_=[];
this.hashMap_=new qf;
for(var b=0;
b<a[x];
++b){
    var c=a[b];
    this.orderedList_[w](c);
    this.hashMap_.set(c.id,c)
}
this.orderedList_[Mc](function(e,f){
    if(e.affinity>f.affinity)return-1;
    else if(f.affinity>e.affinity)return 1;
    else{
        var g=e.affinity||"",h=f.affinity||"";
        if(g>h)return 1;
        else if(h>g)return-1;
        return 0
    }
}
)
};
bk[y].get=function(a){
return this.hashMap_.get(a,j)
};
bk[y].getOrderedList=function(){
return this.orderedList_
};
var jk=function(a,b){
for(var c=p._Messages||[],e=a,f=0;
f<c[x];
f++)if(c[f][a]){
    e=c[f][a];
    break
}
var g=b||{
};
c=function(h,n){
    return n in g?g[n]:h
};
return e=e[B](la("\\{
\\$(\\w+)\\
}
","g"),c)
}
,kk=function(a,b){
q.write(jk(a,b))
};
Hd("_cp_getMsg",jk,void 0);
Hd("_cp_writeMsg",kk,void 0);
var lk=function(a){
this.names_={
};
this.addContactNames(a)
};
Q=lk[y];
Q.addContactNames=function(a){
for(var b=0;
b<a[x];
b++)this.addContactName_(a[b])
};
Q.addContactName_=function(a){
a=this.getGivenAndFamilyNames(a);
this.incrementCounter_(a[0]);
a[1]&&this.incrementCounter_(this.getGivenAndFamilyInitial_(a[0],a[1]))
};
Q.incrementCounter_=function(a){
if(this.names_[a])this.names_[a]+=1;
else this.names_[a]=1
};
Q.getGivenAndFamilyNames=function(a){
return je(a)[Fb](/[\s,]+/)
};
Q.getShortName=function(a){
var b=this.getGivenAndFamilyNames(a),c=b[0];
if(!this.names_[c]||this.names_[c]<=1)return c;
if(b[1]){
    c=this.getGivenAndFamilyInitial_(b[0],b[1]);
    if(!this.names_[c]||this.names_[c]<=1)return c
}
return a
};
Q.getGivenAndFamilyInitial_=function(a,b){
return a+" "+b[Lb](0).toLocaleUpperCase()+"."
};
Q.formatContact=function(a,b,c,e,f){
e=ze(e);
e=la('(^|<| |"|\\()'+e,"i");
if(a&&e[lb](a))return a;
if(c&&a)for(var g=0;
g<c[x];
++g)if(e[lb](c[g]))return a;
if(e[lb](b))return this.emailMaybeWithoutDomain_(b,f);
if(a)return this.getShortName(a);
return this.emailMaybeWithoutDomain_(b,f)
};
Q.emailMaybeWithoutDomain_=function(a,b){
if(b)return a[Fb]("@")[0];
return a
};
var mk=function(){
Wj[$c](this,arguments);
this.showEventCallback_=function(){
}
};
U(mk,Wj);
Q=mk[y];
Q.setParent=function(a){
this.parent_=a
};
Q.setShowEventCallback=function(a){
this.showEventCallback_=a
};
Q.isRowSelectable_=function(a){
if(a.getNumberOfContacts)if(a.getNumberOfContacts()>0)return i;
return k
};
Q.getSuggestedRows=function(){
for(var a=[],b=0;
b<this.rows_[x];
b++){
    var c=this.rows_[b][Bb];
    this.isRowSelectable_(c)&&a[w](c)
}
return a
};
Q.getLastHighlightedRowIndex=function(){
for(var a=this.hilitedRow_,b=0,c=0;
c<a;
c++){
    var e=this.rows_[c][Bb];
    this.isRowSelectable_(e)||b++
}
return a-b
};
Q.addTitle_=function(a,b,c){
a=new nk(a,b);
c[w]({
data:a,id:-1
}
)
};
Q.prerender_=function(){
if(this.rows_[x]!=0){
    if(this.customRenderer_&&this.customRenderer_.setContactFormatter){
        for(var a=new sf,b=0;
        b<this.rows_[x];
        b++)this.rows_[b][Bb].getAllContactNames&&a.addAll(this.rows_[b][Bb].getAllContactNames());
        this.customRenderer_.setContactFormatter(new lk(a.getValues()))
    }
    a=[];
    var c=k,e=k,f=k;
    for(b=0;
    b<this.rows_[x];
    b++){
        var g=this.rows_[b];
        g=g[Bb];
        if(g.getType()==0){
            if(!c&&g.getIsDomainContact()==k){
                c="People";
                this.addTitle_("ContactIcon",c,a);
                c=i
            }
            if(!f&&g.getIsDomainContact()==
                    i){
                f=g.getItem();
                f=f.email;
                f=ok(f);
                if(!f||f=="")f="Domain";
                f=f[Lb](0)[qd]()+f[Sc](1,f[x]);
                f=f+" Contacts";
                this.addTitle_("ContactIcon",f,a);
                f=i
            }
        }
        if(!e&&g.getType()==1){
            e="Groups";
            this.addTitle_("GroupIcon",e,a);
            e=i
        }
        a[w](this.rows_[b])
    }
    this.rows_=a
}
};
Q.renderRowHtml=function(a,b){
var c=a[Bb].getType()=="TITLE";
c=c?j:b;
return mk.superClass_.renderRowHtml[J](this,a,c)
};
Q.redraw=function(){
var a=k;
this.prerender_();
var b=this.rows_[x];
if(b>0&&this.rows_[b-1][Bb].getType&&this.rows_[b-1][Bb].getType()=="MORE")a=i;
mk.superClass_.redraw[J](this);
if(a){
    a=jk("SEARCHING_FOR_MATCHES");
    if(b>1){
        b=this.dom_[K]("div");
        a=this.dom_.createDom("div",{
style:"background-color: #A0B0FF;
margin: 8px 0px"
        }
        );
        if(X){
            var c=this.dom_.createDom("img",{
width:"1",height:"1"
            }
            );
            a[v](c)
        }
        else Xa(a[H],"1px");
        b[v](a);
        this.element_[v](b);
        a=jk("SEARCHING_FOR_MORE_MATCHES")
    }
    b=this.dom_.createDom("div");
    xa(b,a);
    this.element_[v](b);
    if(this.topAlign_){
        b=Hj(this.target_);
        a=Mj(this.element_);
        b.y-=a[P];
        Kj(this.element_,b)
    }
}
this.showEventCallback_()
};
var pk=function(a,b){
this.showExtendedInterface_=a;
this.twoLine_=b;
this.sizeElement_=Ki("div",{
style:"position:absolute;
top:-100px;
left:-1000px;
"
}
,"");
q[dc][v](this.sizeElement_)
};
pk[y].setShowExtendedInterface=function(a){
this.showExtendedInterface_=!!a
};
pk[y].measureText_=function(a){
Wi(this.sizeElement_,a);
return this.sizeElement_[Jb]
};
var ok=function(a){
if(!a)return j;
var b=a[E]("@");
if(b<1)return j;
return a=a[Ed](b+1,a[x]-b-1)
};
Q=pk[y];
Q.setContactFormatter=function(a){
this.contactFormatter_=a
};
Q.renderContacts_=function(a,b,c,e,f){
var g="",h=0;
this.contactFormatter_||this.setContactFormatter(new lk([]));
for(var n=0;
n<a[x];
++n){
    var o=a[n],s=o[N],A=o.email;
    o=o.aliases;
    s=this.contactFormatter_.formatContact(s,A,o,f,b);
    A=this.measureText_(s+", ");
    if(h+A<c||n<e){
        if(n>0)g+=", ";
        g+=se(s);
        h+=A
    }
    else break
}
return{
result:g,count:n,width:h
}
};
Q.renderGroup_=function(a,b){
var c=b.getItem()[N],e=b.getMembers(),f=i,g="";
if(e[x]>0){
    g=ok(e[0].email);
    for(var h=1;
    h<e[x]&&f;
    ++h)f=f&&ok(e[h].email)==g
}
var n=400;
e=0;
if(!this.twoLine_&&c)e=this.measureText_("&lt;
"+c+"&gt;
");
if(f)e+=this.measureText_("@"+g);
var o=2;
h=this.renderContacts_(b.getMatchedMembers(),f,n-e,o,a);
c=h.count;
e+=h[z];
var s=function(A){
    return!Qe(b.getMatchedMembers(),A)
};
s=Me(b.getContacts(),s);
n=this.renderContacts_(s,f,n-e,o-c,a);
c+=n.count;
e+=n[z];
e=h.result;
if(h.count>0&&
        n.count>0)e+=", ";
e+=n.result;
h=b.getMatchedMembers()[x]+s[x];
if(c<h){
    c=h-c;
    if(c>1)h=h="and "+(c+" others<b>...</b>");
    else h="and 1 other<b>...</b>";
    h=jk("AND_OTHERS",{
count:c
    }
    );
    e+=" "+h
}
if(f)e+="@"+g;
return e
};
Q.renderTitle_=function(a,b){
if(this.showExtendedInterface_){
    var c=[],e=a[Bb],f=e.getIconName();
    if(p.manifest&&p.manifest.image&&p.manifest.image[f])f=p.manifest.image[f];
    else f+=".png";
    c[w]('<table style="font-size: 100%;
"><tr>');
    c[w]('<td style="padding: 1px;
" width="15">');
    c[w]('<img src = "'+f+'"></td>');
    c[w]('<td style="padding: 1px;
color: #666666">');
    c[w](se(e.getText()));
    c[w]("</td></tr></table>");
    xa(b,c[ud](""))
}
};
Q.renderRow=function(a,b,c){
var e=a[Bb];
if(!(e instanceof $j))if(e.getType()=="TITLE")this.renderTitle_(a,c);
else{
    a=[];
    var f=e.getType()==1;
    if(this.showExtendedInterface_){
        a[w]('<table style="font-size: 100%;
"><tr>');
        a[w]('<td style="padding: 1px;
" width="15">');
        a[w]("</td>");
        a[w]('<td style="padding: 1px;
">')
    }
    var g=e.getItem()[N];
    g&&a[w]('"'+se(g)+'"');
    this.twoLine_&&g&&a[w]("<br>");
    if(f)if(!g||this.showExtendedInterface_){
        g&&a[w](" (");
        a[w](this.renderGroup_(b,e));
        g&&a[w](")")
    }
    else{
        if(b=e.getItem().members[x]){
            this.twoLine_||
            a[w](" ");
            if(b==1)b="(1 contact)";
            else b=b="("+(b+" contacts)");
            a[w](b)
        }
    }
    else{
        !this.twoLine_&&g&&a[w](" ");
        g&&a[w]("&lt;
");
        a[w](se(e.getItem().email));
        g&&a[w]("&gt;
")
    }
    this.showExtendedInterface_&&a[w]("</td></tr></table>");
    xa(c,a[ud](""))
}
};
var nk=function(a,b){
this.iconName_=a;
this.titleText_=b
};
nk[y].getType=function(){
return"TITLE"
};
nk[y].getIconName=function(){
return this.iconName_
};
nk[y].getText=function(){
return this.titleText_
};
var qk=function(a,b){
this.sendRequestCallback_=this.sendJsonAjax_[gd](this);
this.abbs_={
    LOG_EVENTS:"ls",ROWS_RANK:"nk",ROWS_NUM_CONTACTS:"nc",SUGGESTED_ITEMS:"si",CONTACTS_IN_CONTEXT:"cc",PREFIX_LENGTH:"pl",EVENT_TYPE:"et",EVENT_TYPE_SHOW:"SH",EVENT_TYPE_SELECT:"SE",LIST_GENERATION_MILLIS:"gm",SELECTED_ROW_NUM:"sr"
};
this.logEvents_=[];
this.failedLoggingRequests_=this.lastRequestNumber_=this.lastUserOperationTimestamp_=this.lastSendTimeStamp_=0;
this.authToken_="";
this.isFlushRunning_=k;
this.isEnabled_=
i;
this.emailAc_=a;
var c=T(this.logShowEventNow,this),e=T(this.logSelectEventNow,this),f=T(this.tickUserInput,this);
this.emailAc_.getRenderer().setShowEventCallback(c);
this.emailAc_.getInputHandler().setEventsCallbacks(e,f);
this.loggingUri_=b;
this.timer_=new Bh(1E4);
c=this.flushIfIdleLongEnough_[gd](this);
this.timer_[Lc]("tick",c);
this.timer_[xc]();
c=this.flushBufferNow_[gd](this);
Y(p,"unload",c)
};
Q=qk[y];
Q.setAuthToken=function(a){
this.authToken_=a
};
Q.disableLogging_=function(){
this.isEnabled_=k;
this.logEvents_=[]
};
Q.getNextRequestNumber_=function(){
this.lastRequestNumber_++;
return this.lastRequestNumber_
};
Q.getSuggestedItems_=function(){
for(var a=this.emailAc_.getRenderer().getSuggestedRows(),b=[],c=[],e=0;
e<a[x];
++e){
    b[e]=a[e].getNumberOfContacts();
    c[e]=a[e].getAffinity()
}
a={
};
a[this.abbs_.ROWS_NUM_CONTACTS]=b;
a[this.abbs_.ROWS_RANK]=c;
return a
};
Q.getNumberOfContactsInContext_=function(){
for(var a=this.emailAc_.getInputHandler().getLastValue(),b=this.emailAc_.getInputHandler().getLastPrefix(),c=0,e=a[E]("<");
e!=-1;
){
    c++;
    e=a[E]("<",e+1)
}
b[E]("<")!=-1&&c--;
return c
};
Q.getPrefixLength_=function(){
return this.emailAc_.getInputHandler().getLastPrefix()[x]
};
Q.createBasicEvent_=function(a){
var b={
};
b[this.abbs_.EVENT_TYPE]=a;
b[this.abbs_.SUGGESTED_ITEMS]=this.getSuggestedItems_();
b[this.abbs_.CONTACTS_IN_CONTEXT]=this.getNumberOfContactsInContext_();
b[this.abbs_.PREFIX_LENGTH]=this.getPrefixLength_();
return b
};
Q.validateEvent_=function(a){
a=a[this.abbs_.SUGGESTED_ITEMS];
if(!a)return k;
a=a[this.abbs_.ROWS_NUM_CONTACTS];
return a[x]>0
};
Q.logEvent_=function(a){
if(this.validateEvent_(a)){
    var b=this.logEvents_[x];
    this.logEvents_[b]=a;
    a=b+1;
    a>=10&&this.flushBufferNow_()
}
};
Q.logShowEventNow=function(){
if(this.isEnabled_!=k)if(!(this.getPrefixLength_()>1)){
    var a=this.createBasicEvent_(this.abbs_.EVENT_TYPE_SHOW);
    a[this.abbs_.LIST_GENERATION_MILLIS]=this.emailAc_.getLastListGenerationDurationMillis();
    this.logEvent_(a)
}
};
Q.logSelectEventNow=function(){
if(this.isEnabled_!=k){
    var a=this.createBasicEvent_(this.abbs_.EVENT_TYPE_SELECT);
    a[this.abbs_.SELECTED_ROW_NUM]=this.emailAc_.getRenderer().getLastHighlightedRowIndex()+1;
    this.logEvent_(a)
}
};
Q.tickUserInput=function(){
var a=new Date;
this.lastUserOperationTimestamp_=a[sd]()
};
Q.flushIfIdleLongEnough_=function(){
if(this.lastUserOperationTimestamp_!=0){
    var a=new Date;
    a=a[sd]()-this.lastUserOperationTimestamp_;
    a>6E4&&this.flushBufferNow_()
}
};
Q.flushBufferNow_=function(){
if(!this.isFlushRunning_)if(this.logEvents_[x]!=0){
    this.isFlushRunning_=i;
    var a=this.logEvents_;
    this.logEvents_=[];
    this.sendLoggingRequestToServer_(a)
}
};
Q.sendLoggingRequestToServer_=function(a){
var b={
};
b[this.abbs_.LOG_EVENTS]=a;
a=new xh;
b=a.serialize(b);
this.sendRequestCallback_(b)
};
Q.sendJsonAjax_=function(a){
var b=new Sh(this.loggingUri_);
b.setParameterValue("out","js");
b.setParameterValue("jsx","true");
b.setParameterValue("tok",this.authToken_);
b.setParameterValue("eventsToLog",a);
a=this.getNextRequestNumber_();
this.requestName_="ACLoggingReq"+a;
this.requestPath_="$ACLoggingReq"+a;
this.loggingDS_=new ji(b,this.requestName_,"&&&START&&&","&&&END&&&",i);
b=V();
a=this.ajaxRequestCompleted_[gd](this);
b.addDataSource(this.loggingDS_,i,this.requestName_);
b.addListener(a,this.requestPath_);
this.loggingDS_[Eb]()
};
Q.ajaxRequestCompleted_=function(){
var a=V().getDataSource(this.requestPath_),b=!!a.getChildNode("Success",k).get();
if(b){
    a=a.getChildNode("Body",k).AuthToken.Value;
    this.setAuthToken(a)
}
this.flushCompleted_(b)
};
Q.flushCompleted_=function(a){
var b=new Date;
this.lastSendTimeStamp_=b[sd]();
this.isFlushRunning_=k;
if(!a){
    this.failedLoggingRequests_++;
    this.failedLoggingRequests_>2&&this.disableLogging_()
}
};
var rk=function(){
this.contacts_=[];
this.contactHtmls_=[];
this.inputs_=[];
this.groups_=[];
this.tokenMap_={
};
rk[y].addInput=rk[y].addInput;
rk[y].removeInput=rk[y].removeInput;
rk[y].setTarget=rk[y].setTarget
};
Q=rk[y];
Q.inited_=k;
Q.allowLogging_=i;
Q.lastListGenerationDurationMillis_=0;
Q.showGroups_=k;
Q.includeImplicitGroups_=k;
Q.showExtendedInterface_=k;
Q.unexpandedExplicitGroups_=k;
Q.maxContacts_=250;
Q.showDomainContacts_=k;
Q.domainGroups_=k;
var fk=la("^(?:[A-Za-z0-9!#\\$%\\*\\/\\?\\|\\^\\{
\\
}
`~&'\\+\\-=_](?:[A-Za-z0-9!#\\$%\\*\\/\\?\\|\\^\\{
\\
}
`~&'\\+\\-=_\\.]*[A-Za-z0-9!#\\$%\\*\\/\\?\\|\\^\\{
\\
}
`~&'\\+\\-=_])?@[\\.A-Za-z0-9\\-]+)$"),ek=la("^(.+?)??(?:<((?:[A-Za-z0-9!#\\$%\\*\\/\\?\\|\\^\\{
\\
}
`~&'\\+\\-=_](?:[A-Za-z0-9!#\\$%\\*\\/\\?\\|\\^\\{
\\
}
`~&'\\+\\-=_\\.]*[A-Za-z0-9!#\\$%\\*\\/\\?\\|\\^\\{
\\
}
`~&'\\+\\-=_])?@[\\.A-Za-z0-9\\-]+))>)?,?$");
rk[y].usageLogger_=j;
rk[y].addContact=function(a,b,c){
if(!a||Od(a)){
    c={
id:c||""
    }
    ;
    if(a)c.Name=a;
    if(b)c.Emails=[{
Address:b
    }
    ];
    a=hi(c,"$SomeContact")
}
a=this.createContactNodes_(a);
for(b=0;
b<a[x];
b++)this.contacts_[w](a[b])
};
var sk=function(a){
var b=[],c=a.getChildNode("Emails");
if(c){
    c=c.getChildNodes();
    for(var e=0,f=c.getCount();
    e<f;
    ++e)b[w](c.getByIndex(e).getChildNodeValue("Address"))
}
a=W("Email").getValue(a);
b[x]==0&&a!=j&&b[w](a);
return b
}
,tk=function(a,b){
var c=new rk;
if(!b.uri&&b.serverBase)b.uri=b.serverBase+"data/contacts";
if(!b.loggingUri&&b.serverBase)b.loggingUri=b.serverBase+"log/emailautocomplete";
c.create(a,b);
return c
};
S._EmailAc_create=tk;
Q=rk[y];
Q.create=function(a,b){
var c=zi(a);
if(b.groups){
    this.showGroups_=i;
    this.includeImplicitGroups_=!!b.implicitGroups
}
if(b.extendedInterface)this.showExtendedInterface_=i;
if(b.unexpandedGroups)this.unexpandedExplicitGroups_=i;
if(b.domainGroups)this.domainGroups_=i;
if(b.debugData)this.debugData_=b.debugData;
if(b.inputHandler)this.inputHandler_=b.inputHandler;
b.max&&this.setMaxContacts(b.max);
var e=new Sh(b.uri);
if(b.disableLogging)this.allowLogging_=k;
if(this.allowLogging_)this.loggingUri_=(new Sh(b.loggingUri))[db]();
this.init(c,e[db](),b.rightAlign,b.twoLine,b.multi,b.topAlign,b.onComplete)
};
Q.dispose=function(){
this.inputHandler_.dispose();
this.renderer_.dispose()
};
Q.createAutoComplete=function(){
return new bj(this,this.renderer_,this.inputHandler_)
};
Q.getInputHandler=function(){
return this.inputHandler_
};
Q.getRenderer=function(){
return this.renderer_
};
Q.setMaxContacts=function(a){
this.maxContacts_=a<0?10100:a
};
Q.setTarget=function(a){
this.ac_.setTarget(a)
};
Q.getBodyElementFromInput_=function(a){
var b=j;
if(a)if(Md(a)){
    if(a[x]>0)b=a[0][fc][dc]
}
else b=a[fc][dc];
return b
};
Q.init=function(a,b,c,e,f,g,h){
if(this.inited_)Uf.warning("Init already called");
else{
    this.inited_=i;
    this.uri_=b;
    this.matcher_=new ck(this.showGroups_,this.showExtendedInterface_);
    this.debugData_||this.loadContactDataSource_("$Contacts",T(this.gotContacts,this),"",k);
    this.bodyToRenderOn_=this.getBodyElementFromInput_(a);
    this.rowRenderer_=new pk(this.showExtendedInterface_,e);
    this.renderer_=new mk(this.bodyToRenderOn_,this.rowRenderer_,c);
    this.renderer_.setAutoPosition(i);
    if(!this.inputHandler_)this.inputHandler_=
    new Zj(",;
",'"',f,this.unexpandedExplicitGroups_);
    this.ac_=this.createAutoComplete();
    this.inputHandler_.attachAutoComplete(this.ac_);
    if(g){
        this.renderer_.setTopAlign(i);
        this.inputHandler_.setUpsideDown(i)
    }
    h&&Y(this.ac_,"update",function(n){
        n.row&&h(n[I].getTarget())
    }
    );
    if(this.debugData_){
        b=V();
        b.addDataSource(this.debugData_.contacts);
        this.gotContacts("$Contacts","")
    }
    a&&this.addInput(a)
}
};
Q.turnOnUsageLogging_=function(){
if(this.allowLogging_&&!this.usageLogger_)this.usageLogger_=new qk(this,this.loggingUri_)
};
Q.loadContactDataSource_=function(a,b,c,e){
var f=new Sh(this.uri_);
f.setParameterValue("out","js");
if(c){
    f.setParameterValue("tok",c);
    f.setParameterValue("cl","false");
    f.setParameterValue("psort","Name")
}
e&&f.setParameterValue("cd","true");
this.showGroups_&&f.setParameterValue("groups","true");
this.includeImplicitGroups_&&f.setParameterValue("igroups","true");
this.domainGroups_&&f.setParameterValue("dg","true");
c=c?10:this.maxContacts_;
f.setParameterValue("max",m(c));
f=new ji(f,a,"&&&START&&&","&&&END&&&");
c=V();
c.addDataSource(f,i);
c.addListener(b,a);
f[Eb]()
};
Q.addInput=function(a){
if(this.inited_){
    if(Md(a)){
        if(a[x]==0)return;
        this.inputs_=this.inputs_[Kb](a);
        for(var b=0;
        b<a[x];
        b++)this.inputHandler_.attachInputs[J](this.inputHandler_,a[b])
    }
    else{
        this.inputs_[w](a);
        this.inputHandler_.attachInputs[J](this.inputHandler_,a)
    }
    if(!this.bodyToRenderOn_){
        this.bodyToRenderOn_=this.getBodyElementFromInput_(a);
        this.renderer_.setParent(this.bodyToRenderOn_)
    }
}
else Uf.warning("Init should be called first")
};
Q.removeInput=function(a){
if(this.inited_)if(Md(a))Le(a,function(b){
    this.removeInput(b)
}
,this);
else{
    Se(this.inputs_,a);
    this.inputHandler_.detachInputs(a)
}
else Uf.warning("Init should be called first")
};
Q.requestMatchingRows=function(a,b,c,e){
this.curToken_=a;
var f=[],g=new Date;
if(a!=""){
    if(!this.matcher_)return;
    f=this.matcher_.requestMatchingRows(a,b,e)
}
if(this.showDomainContacts_&&a)if(!this.hasAllMatchesFor_(a,b,i))if(f[x]<b){
    e=f[Kb]([]);
    S[yb](T(this.getAdditonalContacts_,this,e,b,a,c),500);
    f[w](new $j("MORE"))
}
b=new Date;
this.lastListGenerationDurationMillis_=g=b[sd]()-g[sd]();
c(a,f)
};
Q.getLastListGenerationDurationMillis=function(){
return this.lastListGenerationDurationMillis_
};
Q.hasAllMatchesFor_=function(a,b,c){
var e=this.tokenMap_[a];
return e&&(c||e.count<b)?i:a[x]>1?this.hasAllMatchesFor_(a[Sc](0,a[x]-1),b,k):k
};
var uk=0;
Q=rk[y];
Q.getAdditonalContacts_=function(a,b,c,e){
if(c==this.curToken_&&c!=""){
    var f="$AdditionalContacts"+uk++;
    a=T(this.gotAdditionalContacts_,this,a,b,c,e);
    this.loadContactDataSource_(f,a,c,i)
}
};
Q.isContactAdded_=function(a,b,c){
return(a=a[b])&&Qe(a,c)
};
Q.gotAdditionalContacts_=function(a,b,c,e,f){
var g=[][Kb](a);
if(c==this.curToken_){
    f=this.getContactsFromResponse_(f);
    for(var h={
    }
    ,n=0;
    n<a[x];
    n++)if(a[n].getType()==0){
        var o=a[n].getItem().email,s=a[n].getItem()[N];
        if(h[o])h[o][w](s);
        else h[o]=[s]
    }
    for(n=0;
    g[x]<b&&n<f.getCount();
    ){
        a=f.getByIndex(n);
        var A=sk(a);
        s=a.Name;
        for(var G=0;
        G<A[x];
        G++){
            o=A[G];
            if(!this.isContactAdded_(h,o,s)){
                o=this.createContactNode_(a,o);
                g[w](new hk(o,o.affinity,i));
                this.contacts_[w](o)
            }
        }
        n++
    }
    e(c,g,i);
    this.tokenMap_[c]={
count:g[x]
    }
}
};
Q.getContactsFromResponse_=function(a){
a=V().getDataSource(a);
return a=a.getChildNode("Body",i).getChildNode("Contacts",i).getChildNodes()
};
Q.buildGroups=function(a,b,c,e,f){
if(e!=j)for(var g=e[x],h=0;
h<g;
h++){
    var n=e[h].id,o=a.get(n);
    if(o){
        if(f)o.implicit=i;
        o.members[w](c);
        n[Lb](0)!="^"&&b[w](o)
    }
}
};
Q.getAuthTokenFromResponse_=function(a){
a=V().getDataSource(a);
a=a.getChildNode("Body",i).AuthToken;
return a.Value
};
Q.getUsageLoggingEnabledFromResponse_=function(a){
a=V().getDataSource(a);
a=a.getChildNode("Body",i).UsageLoggingEnabled;
return!!a
};
Q.gotContacts=function(a){
if(this.getUsageLoggingEnabledFromResponse_(a)&&this.allowLogging_){
    this.turnOnUsageLogging_();
    var b=this.getAuthTokenFromResponse_(a);
    this.usageLogger_.setAuthToken(b)
}
b=[];
var c=[],e=new qf,f=V().getDataSource(a),g=f.getChildNode("Body").getChildNode("UserData");
if(g){
    this.showDomainContacts_=!!g.getChildNodeValue("ShowDomainContacts");
    this.includeImplicitGroups_=this.includeImplicitGroups_&&!!g.getChildNodeValue("ShowImplicitGroups");
    this.showExtendedInterface_=this.showExtendedInterface_&&
    !!g.getChildNodeValue("EmailAcExtendedInterface");
    this.rowRenderer_.setShowExtendedInterface(this.showExtendedInterface_);
    this.matcher_.setOrderByType(this.showExtendedInterface_)
}
if(this.showGroups_){
    if(f=f.getChildNode("Body").getChildNode("Groups")){
        var h=f.getChildNodes();
        f=h.getCount();
        Uf.info("Got "+f+" groups");
        for(g=0;
        g<f;
        g++){
            var n=h.getByIndex(g),o=n.getChildNodeValue("id");
            if(!(n.IsLocked&&!(this.unexpandedExplicitGroups_&&o=="^Mine"))){
                n=this.createGroupNode(n);
                c[w](n);
                e.set(o,n)
            }
        }
    }
    Uf.info("Created groups array")
}
a=
this.getContactsFromResponse_(a);
f=a.getCount();
Uf.info("Got "+f+" contacts");
if(f>0)for(g=0;
g<this.inputs_[x];
g++)this.inputs_[g][Pc]("autocomplete","off");
for(g=0;
g<f;
g++){
    o=a.getByIndex(g);
    n=sk(o);
    for(var s=0;
    s<n[x];
    s++){
        h=n[s];
        var A=this.createContactNode_(o,h);
        if(this.showGroups_&&s==0){
            var G=[];
            h=o.getChildNodeValue("Groups");
            this.buildGroups(e,G,A,h,k);
            if(this.includeImplicitGroups_){
                h=o.getChildNodeValue("ImplicitGroups");
                this.buildGroups(e,G,A,h,i)
            }
            if(G[x]>0)A.groups=G
        }
        b[w](A)
    }
}
Uf.info("Created contacts array");
this.contacts_=b;
this.groups_=c;
this.matcher_.setDataSource(this.contacts_,this.groups_);
Uf.info("Set data source for matcher")
};
Q.createContactNode_=function(a,b){
var c=a.Id,e=a.Name,f=a.Affinity,g=!!a.DomainContact;
f||(f=0);
var h={
};
h.data=a;
h.id=c;
Ua(h,e);
h.email=b;
h.isDomainContact=g;
if(c=a.getChildNode("NameAliases",i)){
    c=c.getChildNodes();
    g=c.getCount();
    for(var n=[],o=0;
    o<g;
    ++o)n[w](c.getByIndex(o).get());
    h.aliases=n
}
h.affinity=f;
e=vk(e,b);
h.formattedValue=e;
h.groups=[];
na(h,function(){
    return this.formattedValue
}
);
return h
};
Q.createContactNodes_=function(a){
for(var b=sk(a),c=[],e=0;
e<b[x];
e++){
    var f=b[e];
    f=this.createContactNode_(a,f);
    c[w](f)
}
return c
};
Q.createGroupNode=function(a){
return{
members:[],data:a,id:a.id,affinity:a.Affinity||0,name:a.Name,toString:function(){
        return this[N]
    }
}
};
var _emailAutocomplete=S._emailAutocomplete=new rk;
S._initEmailAutocomplete=T(S._emailAutocomplete.init,S._emailAutocomplete);
var _initEmailAutocomplete=S._initEmailAutocomplete,vk=function(a,b){
var c=a?'"'+a+'"':"",e=b?" <"+b+">":"";
return c+e
};
var wk=function(a,b,c){
this.parent_=c;
this.dataName_=b;
this.setRoot(a)
};
Q=wk[y];
Q.setRoot=function(a){
this.root_=a;
this.childNodeList_=j
};
Q.get=function(){
return!Rd(this.root_)?this.root_:this.getChildNodes()
};
Q.set=function(a){
if(a&&Rd(this.root_))d(l("Can't set group nodes to new values yet"));
if(this.parent_)this.parent_.root_[this.dataName_]=a;
this.root_=a;
this.childNodeList_=j;
V().fireDataChange(this.getDataPath())
};
Q.getChildNodes=function(a){
if(!this.root_)return new Rf;
if(!a||a=="*"){
    this.createChildNodes_(k);
    return this.childNodeList_
}
else if(a[E]("*")==-1)return this.root_[a]!=j?new Sf([this.getChildNode(a)]):new Rf;
else d(l("Selector not supported yet ("+a+")"))
};
Q.createChildNodes_=function(a){
if(!(this.childNodeList_&&!a))if(Rd(this.root_)){
    a=new Sf;
    var b;
    if(Md(this.root_))for(var c=this.root_[x],e=0;
    e<c;
    e++){
        b=this.root_[e];
        var f=b.id;
        f=f!=j?m(f):"["+e+"]";
        b=new wk(b,f,this);
        a.add(b)
    }
    else for(f in this.root_){
        c=this.root_[f];
        if(c.getDataName)a.add(c);
        else if(!Qd(c)){
            b=new wk(c,f,this);
            a.add(b)
        }
    }
    this.childNodeList_=a
}
else this.childNodeList_=new Rf
};
Q.getChildNode=function(a,b){
if(!this.root_)return j;
var c=this.getChildNodes().get(a);
if(!c&&b){
    c={
    }
    ;
    if(Md(this.root_)){
        c.id=a;
        this.root_[w](c)
    }
    else this.root_[a]=c;
    c=new wk(c,a,this);
    this.childNodeList_&&this.childNodeList_.add(c)
}
return c
};
Q.getChildNodeValue=function(a){
if(this.childNodeList_)return(a=this.getChildNodes().get(a))?a.get():j;
else return this.root_?this.root_[a]:j
};
Q.setChildNode=function(a,b){
var c=j,e=j,f=k;
if(b!=j)if(b.getDataName){
    e=b;
    e.parent_=this
}
else e=Md(b)||Rd(b)?new wk(b,a,this):new xk(this.root_,a,this);
if(Md(this.root_)){
    this.createChildNodes_();
    var g=this.childNodeList_[E](a);
    if(b==j){
        var h=this.childNodeList_.get(a);
        if(h)c=h.getDataPath();
        this.root_[rd](g,1)
    }
    else if(g)this.root_[g]=b;
    else this.root_[w](b);
    if(g==j)f=i;
    this.childNodeList_.setNode(a,e)
}
else if(Rd(this.root_)){
    if(b==j){
        this.createChildNodes_();
        if(h=this.childNodeList_.get(a))c=h.getDataPath();
        delete this.root_[a]
    }
    else{
        this.root_[a]||(f=i);
        this.root_[a]=b
    }
    this.childNodeList_&&this.childNodeList_.setNode(a,e)
}
g=V();
if(e){
    g.fireDataChange(e.getDataPath());
    if(f&&this.isList()){
        g.fireDataChange(this.getDataPath());
        g.fireDataChange(this.getDataPath()+"/count()")
    }
}
else if(c){
    g.fireDataChange(c);
    if(this.isList()){
        g.fireDataChange(this.getDataPath());
        g.fireDataChange(this.getDataPath()+"/count()")
    }
}
return e
};
Q.getDataName=function(){
return this.dataName_
};
Q.setDataName=function(a){
this.dataName_=a
};
Q.getDataPath=function(){
var a="";
if(this.parent_)a=this.parent_.getDataPath()+"/";
return a+this.dataName_
};
wa(Q,function(){
}
);
Q.isList=function(){
return this.isList_!=j?this.isList_:Md(this.root_)
};
var xk=function(a,b,c){
this.dataName_=b;
this.parent_=a;
this.parentDataNode_=c||this.parent_
};
U(xk,Qf);
xk[y].get=function(){
return this.parent_[this.dataName_]
};
xk[y].set=function(a){
var b=this.parent_[this.dataName_];
this.parent_[this.dataName_]=a;
b!=a&&V().fireDataChange(this.getDataPath())
};
xk[y].getDataName=function(){
return this.dataName_
};
xk[y].getParent_=function(){
return this.parentDataNode_
};
var yk=function(a){
this.element_=a;
a=X?"focusin":"focus";
var b=X?"focusout":"blur";
this.listenKeyIn_=Y(this.element_,a,this,!X);
this.listenKeyOut_=Y(this.element_,b,this,!X)
};
U(yk,uh);
La(yk[y],function(a){
var b=a.getBrowserEvent();
b=new Kg(b);
Oa(b,a[Zc]=="focusin"||a[Zc]=="focus"?"focusin":"focusout");
try{
    this[F](b)
}
finally{
    b.dispose()
}
}
);
yk[y].disposeInternal=function(){
yk.superClass_.disposeInternal[J](this);
nh(this.listenKeyIn_);
nh(this.listenKeyOut_);
delete this.element_
};
var zk=function(a,b,c){
Ea(this,a);
this.handle=b||a;
this.limits=c||new vj(NaN,NaN,NaN,NaN);
this.document_=xi(a);
this.eventHandler_=new jj(this);
Y(this.handle,"mousedown",this.startDrag,k,this)
};
U(zk,uh);
var Ak=X||mg&&Dg("1.9.3");
Q=zk[y];
Fa(Q,0);
Ga(Q,0);
Q.startX=0;
Q.startY=0;
Q.deltaX=0;
Q.deltaY=0;
Q.enabled_=i;
Q.dragging_=k;
Q.hysteresisDistanceSquared_=0;
Q.mouseDownTime_=0;
Q.ieDragStartCancellingOn_=k;
Q.getHandler=function(){
return this.eventHandler_
};
Q.setEnabled=function(a){
this.enabled_=a
};
Q.disposeInternal=function(){
zk.superClass_.disposeInternal[J](this);
lh(this.handle,"mousedown",this.startDrag,k,this);
this.eventHandler_.dispose();
delete this[I];
delete this.handle;
delete this.eventHandler_
};
Q.startDrag=function(a){
if(this.enabled_&&!this.dragging_&&(a[Zc]!="mousedown"||a.isButton(0))){
    if(this.hysteresisDistanceSquared_==0){
        this.initializeDrag_(a);
        if(this.dragging_)a[Sb]();
        else return
    }
    else a[Sb]();
    this.setupDragHandlers();
    Fa(this,this.startX=a[jc]);
    Ga(this,this.startY=a[kc]);
    this.deltaX=this[I].offsetLeft;
    this.deltaY=this[I][nd];
    this.pageScroll=yi(this.document_).getDocumentScroll();
    this.mouseDownTime_=$d()
}
};
Q.setupDragHandlers=function(){
var a=this.document_,b=a[Dd],c=!Ak;
this.eventHandler_.listen(a,"mousemove",this.mouseMoved_,c);
this.eventHandler_.listen(a,"mouseup",this.endDrag,c);
if(Ak){
    b.setCapture(k);
    this.eventHandler_.listen(b,"losecapture",this.endDrag)
}
else this.eventHandler_.listen(Ii(a),"blur",this.endDrag);
X&&this.ieDragStartCancellingOn_&&this.eventHandler_.listen(a,"dragstart",Jg);
this.scrollTarget_&&this.eventHandler_.listen(this.scrollTarget_,"scroll",this.onScroll_,c)
};
Q.initializeDrag_=function(a){
a=this[F](new Bk("start",this,a[Bd],a[Cd],a));
if(a!==k)this.dragging_=i
};
Q.endDrag=function(a,b){
this.eventHandler_.removeAll();
Ak&&this.document_.releaseCapture();
if(this.dragging_){
    this.dragging_=k;
    var c=this.limitX(this.deltaX),e=this.limitY(this.deltaY);
    this[F](new Bk("end",this,a[Bd],a[Cd],a,c,e,b))
}
};
Q.mouseMoved_=function(a){
if(this.enabled_){
    var b=a[jc]-this[jc],c=a[kc]-this[kc];
    Fa(this,a[jc]);
    Ga(this,a[kc]);
    if(!this.dragging_){
        var e=this.startX-this[jc],f=this.startY-this[kc];
        e=e*e+f*f;
        if(e>this.hysteresisDistanceSquared_){
            this.initializeDrag_(a);
            if(!this.dragging_){
                this.endDrag(a);
                return
            }
        }
    }
    c=this.calculatePosition_(b,c);
    b=c.x;
    c=c.y;
    if(this.dragging_){
        e=this[F](new Bk("beforedrag",this,a[Bd],a[Cd],a,b,c));
        if(e!==k){
            this.doDrag(a,b,c,k);
            a[Sb]()
        }
    }
}
};
Q.calculatePosition_=function(a,b){
var c=yi(this.document_).getDocumentScroll();
a+=c.x-this.pageScroll.x;
b+=c.y-this.pageScroll.y;
this.pageScroll=c;
this.deltaX+=a;
this.deltaY+=b;
c=this.limitX(this.deltaX);
var e=this.limitY(this.deltaY);
return new ki(c,e)
};
Q.onScroll_=function(a){
var b=this.calculatePosition_(0,0);
Ya(a,this.pageScroll.x-this[jc]);
Za(a,this.pageScroll.x-this[kc]);
this.doDrag(a,b.x,b.y,i)
};
Q.doDrag=function(a,b,c){
this.defaultAction(b,c);
this[F](new Bk("drag",this,a[Bd],a[Cd],a,b,c))
};
Q.limitX=function(a){
var b=this.limits,c=!ia(b[ec])?b[ec]:j;
b=!ia(b[z])?b[z]:0;
b=c!=j?c+b:aa;
c=c!=j?c:-aa;
return r.min(b,r.max(c,a))
};
Q.limitY=function(a){
var b=this.limits,c=!ia(b.top)?b.top:j;
b=!ia(b[P])?b[P]:0;
b=c!=j?c+b:aa;
c=c!=j?c:-aa;
return r.min(b,r.max(c,a))
};
Q.defaultAction=function(a,b){
Da(this[I][H],a+"px");
this[I][H].top=b+"px"
};
var Bk=function(a,b,c,e,f,g,h,n){
Ig[J](this,a);
Ya(this,c);
Za(this,e);
this.browserEvent=f;
Da(this,g!==ba?g:b.deltaX);
this.top=h!==ba?h:b.deltaY;
this.dragger=b;
this.dragCanceled=!!n
};
U(Bk,Ig);
var Dk=function(a){
this.dom_=a||yi();
this.rightToLeft_=Ck
};
U(Dk,uh);
Dk[y].idGenerator_=Vj.getInstance();
var Ck=j,Ek={
BEFORE_SHOW:"beforeshow",SHOW:"show",HIDE:"hide",DISABLE:"disable",ENABLE:"enable",HIGHLIGHT:"highlight",UNHIGHLIGHT:"unhighlight",ACTIVATE:"activate",DEACTIVATE:"deactivate",SELECT:"select",UNSELECT:"unselect",CHECK:"check",UNCHECK:"uncheck",FOCUS:"focus",BLUR:"blur",OPEN:"open",CLOSE:"close",ENTER:"enter",LEAVE:"leave",ACTION:"action",CHANGE:"change"
}
,Fk=function(a,b){
switch(a){
case 1:return b?"disable":"enable";
case 2:return b?"highlight":"unhighlight";
case 4:return b?"activate":"deactivate";
case 8:return b?"select":"unselect";
case 16:return b?"check":"uncheck";
case 32:return b?"focus":"blur";
case 64:return b?"open":"close"
}
d(l("Invalid component state"))
};
Q=Dk[y];
Q.id_=j;
Q.inDocument_=k;
Q.element_=j;
Q.rightToLeft_=j;
Q.model_=j;
Q.parent_=j;
Q.children_=j;
Q.childIndex_=j;
Q.wasDecorated_=k;
Q.getId=function(){
return this.id_||(this.id_=this.idGenerator_.getNextUniqueId())
};
Q.setId=function(a){
if(this.parent_&&this.parent_.childIndex_){
    hf(this.parent_.childIndex_,this.id_);
    jf(this.parent_.childIndex_,a,this)
}
this.id_=a
};
Q.getElement=function(){
return this.element_
};
Q.setElementInternal=function(a){
this.element_=a
};
Q.getHandler=function(){
return this.googUiComponentHandler_||(this.googUiComponentHandler_=new jj(this))
};
Q.setParent=function(a){
if(this==a)d(l("Unable to set parent component"));
if(a&&this.parent_&&this.id_&&this.parent_.getChild(this.id_)&&this.parent_!=a)d(l("Unable to set parent component"));
this.parent_=a;
Dk.superClass_.setParentEventTarget[J](this,a)
};
Q.getParent=function(){
return this.parent_
};
Q.setParentEventTarget=function(a){
if(this.parent_&&this.parent_!=a)d(l("Method not supported"));
Dk.superClass_.setParentEventTarget[J](this,a)
};
Q.getDomHelper=function(){
return this.dom_
};
Q.isInDocument=function(){
return this.inDocument_
};
Q.createDom=function(){
this.element_=this.dom_[K]("div")
};
Q.render=function(a){
this.render_(a)
};
Q.render_=function(a,b){
if(this.inDocument_)d(l("Component already rendered"));
this.element_||this.createDom();
a?a[Ub](this.element_,b||j):this.dom_.getDocument()[dc][v](this.element_);
if(!this.parent_||this.parent_.isInDocument())this.enterDocument()
};
Q.decorate=function(a){
if(this.inDocument_)d(l("Component already rendered"));
else if(a&&this.canDecorate(a)){
    this.wasDecorated_=i;
    if(!this.dom_||this.dom_.getDocument()!=xi(a))this.dom_=yi(a);
    this.decorateInternal(a);
    this.enterDocument()
}
else d(l("Invalid element to decorate"))
};
Q.canDecorate=function(){
return i
};
Q.decorateInternal=function(a){
this.element_=a
};
Q.enterDocument=function(){
this.inDocument_=i;
this.forEachChild(function(a){
    !a.isInDocument()&&a.getElement()&&a.enterDocument()
}
)
};
Q.exitDocument=function(){
this.forEachChild(function(a){
    a.isInDocument()&&a.exitDocument()
}
);
this.googUiComponentHandler_&&this.googUiComponentHandler_.removeAll();
this.inDocument_=k
};
Q.disposeInternal=function(){
Dk.superClass_.disposeInternal[J](this);
this.inDocument_&&this.exitDocument();
if(this.googUiComponentHandler_){
    this.googUiComponentHandler_.dispose();
    delete this.googUiComponentHandler_
}
this.forEachChild(function(a){
    a.dispose()
}
);
!this.wasDecorated_&&this.element_&&Ri(this.element_);
this.parent_=this.model_=this.element_=this.childIndex_=this.children_=j
};
Q.getModel=function(){
return this.model_
};
Q.setModel=function(a){
this.model_=a
};
Q.addChild=function(a,b){
this.addChildAt(a,this.getChildCount(),b)
};
Q.addChildAt=function(a,b,c){
if(a.inDocument_&&(c||!this.inDocument_))d(l("Component already rendered"));
if(b<0||b>this.getChildCount())d(l("Child component index out of bounds"));
if(!this.childIndex_||!this.children_){
    this.childIndex_={
    }
    ;
    this.children_=[]
}
if(a.getParent()==this){
    var e=a.getId();
    this.childIndex_[e]=a;
    Se(this.children_,a)
}
else jf(this.childIndex_,a.getId(),a);
a.setParent(this);
Xe(this.children_,b,0,a);
if(a.inDocument_&&this.inDocument_&&a.getParent()==this){
    c=this.getContentElement();
    c[Ub](a.getElement(),c[bd][b]||j)
}
else if(c){
    this.element_||this.createDom();
    b=this.getChildAt(b+1);
    a.render_(this.getContentElement(),b?b.element_:j)
}
else this.inDocument_&&!a.inDocument_&&a.element_&&a.enterDocument()
};
Q.getContentElement=function(){
return this.element_
};
Q.isRightToLeft=function(){
if(this.rightToLeft_==j)this.rightToLeft_=Ij(this.inDocument_?this.element_:this.dom_.getDocument()[dc]);
return this.rightToLeft_
};
Q.setRightToLeft=function(a){
if(this.inDocument_)d(l("Component already rendered"));
this.rightToLeft_=a
};
Q.hasChildren=function(){
return!!this.children_&&this.children_[x]!=0
};
Q.getChildCount=function(){
return this.children_?this.children_[x]:0
};
Q.getChild=function(a){
return this.childIndex_&&a?kf(this.childIndex_,a)||j:j
};
Q.getChildAt=function(a){
return this.children_?this.children_[a]||j:j
};
Q.forEachChild=function(a,b){
this.children_&&Le(this.children_,a,b)
};
Q.indexOfChild=function(a){
return this.children_&&a?Ke(this.children_,a):-1
};
Q.removeChild=function(a,b){
if(a){
    var c=Od(a)?a:a.getId();
    a=this.getChild(c);
    if(c&&a){
        hf(this.childIndex_,c);
        Se(this.children_,a);
        if(b){
            a.exitDocument();
            a.element_&&Ri(a.element_)
        }
        a.setParent(j)
    }
}
if(!a)d(l("Child is not in parent component"));
return a
};
Q.removeChildAt=function(a,b){
return this[hc](this.getChildAt(a),b)
};
Q.removeChildren=function(a){
for(;
this.hasChildren();
)this.removeChildAt(0,a)
};
var Hk=function(a,b,c){
Dk[J](this,c);
this.class_=a||"modal-dialog";
this.useIframeMask_=!!b;
this.buttons_=Gk()
};
U(Hk,Dk);
Q=Hk[y];
Q.focusHandler_=j;
Q.escapeToCancel_=i;
Q.hasTitleCloseButton_=i;
Q.useIframeMask_=k;
Q.modal_=i;
Q.draggable_=i;
Q.backgroundElementOpacity_=0.5;
Q.title_="";
Q.content_="";
Q.buttons_=j;
Q.dragger_=j;
Q.visible_=k;
Q.disposeOnHide_=k;
Q.bgEl_=j;
Q.bgIframeEl_=j;
Q.titleEl_=j;
Q.titleTextEl_=j;
Q.titleId_=j;
Q.titleCloseEl_=j;
Q.contentEl_=j;
Q.buttonEl_=j;
Q.getTitle=function(){
return this.title_
};
Q.setContent=function(a){
this.content_=a;
if(this.contentEl_)xa(this.contentEl_,a)
};
Q.getContent=function(){
return this.content_
};
Q.renderIfNoDom_=function(){
this.getElement()||this.render()
};
Q.getContentElement=function(){
this.renderIfNoDom_();
return this.contentEl_
};
Q.getDialogElement=function(){
this.renderIfNoDom_();
return this.getElement()
};
Q.createDraggableTitleDom_=function(){
var a=new zk(this.getElement(),this.titleEl_);
ui(this.titleEl_,this.class_+"-title-draggable");
return a
};
Q.createDom=function(){
this.manageBackgroundDom_();
var a=this.getDomHelper();
this.setElementInternal(a.createDom("div",{
className:this.class_,tabIndex:0
}
,this.titleEl_=a.createDom("div",{
className:this.class_+"-title",id:this.getId()
}
,this.titleTextEl_=a.createDom("span",this.class_+"-title-text",this.title_),this.titleCloseEl_=a.createDom("span",this.class_+"-title-close")),this.contentEl_=a.createDom("div",this.class_+"-content"),this.buttonEl_=a.createDom("div",this.class_+"-buttons"),this.tabCatcherEl_=
a.createDom("span",{
tabIndex:0
}
)));
this.titleId_=this.titleEl_.id;
dj(this.getElement(),"dialog");
ej(this.getElement(),"labelledby",this.titleId_||"");
if(this.content_)xa(this.contentEl_,this.content_);
Qj(this.titleCloseEl_,this.hasTitleCloseButton_);
Qj(this.getElement(),k);
this.buttons_&&this.buttons_.attachToElement(this.buttonEl_)
};
Q.manageBackgroundDom_=function(){
if(this.useIframeMask_&&this.modal_&&!this.bgIframeEl_){
    var a;
    a=this.getDomHelper();
    this.bgIframeEl_=a=a.createDom("iframe",{
frameborder:0,style:"border:0;
vertical-align:bottom;
",src:'javascript:""'
    }
    );
    t(this.bgIframeEl_,this.class_+"-bg");
    Qj(this.bgIframeEl_,k);
    Pj(this.bgIframeEl_,0)
}
else if((!this.useIframeMask_||!this.modal_)&&this.bgIframeEl_){
    Ri(this.bgIframeEl_);
    this.bgIframeEl_=j
}
if(this.modal_&&!this.bgEl_){
    this.bgEl_=this.getDomHelper().createDom("div",this.class_+
    "-bg");
    Pj(this.bgEl_,this.backgroundElementOpacity_);
    Qj(this.bgEl_,k)
}
else if(!this.modal_&&this.bgEl_){
    Ri(this.bgEl_);
    this.bgEl_=j
}
};
Q.render=function(a){
if(this.isInDocument())d(l("Component already rendered"));
this.getElement()||this.createDom();
a=a||this.getDomHelper().getDocument()[dc];
this.renderBackground_(a);
Hk.superClass_.render[J](this,a)
};
Q.renderBackground_=function(a){
this.bgIframeEl_&&a[v](this.bgIframeEl_);
this.bgEl_&&a[v](this.bgEl_)
};
Q.canDecorate=function(a){
return a&&a[dd]&&a[dd]=="DIV"&&Hk.superClass_.canDecorate[J](this,a)
};
Q.decorateInternal=function(a){
Hk.superClass_.decorateInternal[J](this,a);
ui(this.getElement(),this.class_);
a=this.class_+"-content";
if(this.contentEl_=Bi(j,a,this.getElement())[0])this.content_=this.contentEl_.innerHTML;
else{
    this.contentEl_=this.getDomHelper().createDom("div",a);
    if(this.content_)xa(this.contentEl_,this.content_);
    this.getElement()[v](this.contentEl_)
}
a=this.class_+"-title";
var b=this.class_+"-title-text",c=this.class_+"-title-close";
if(this.titleEl_=Bi(j,a,this.getElement())[0]){
    this.titleTextEl_=
    Bi(j,b,this.titleEl_)[0];
    this.titleCloseEl_=Bi(j,c,this.titleEl_)[0]
}
else{
    this.titleEl_=this.getDomHelper().createDom("div",a);
    this.getElement()[Ub](this.titleEl_,this.contentEl_)
}
if(this.titleTextEl_)this.title_=aj(this.titleTextEl_);
else{
    this.titleTextEl_=this.getDomHelper().createDom("span",b,this.title_);
    this.titleEl_[v](this.titleTextEl_)
}
ej(this.getElement(),"labelledby",this.titleId_||"");
if(!this.titleCloseEl_){
    this.titleCloseEl_=this.getDomHelper().createDom("span",c);
    this.titleEl_[v](this.titleCloseEl_)
}
Qj(this.titleCloseEl_,
this.hasTitleCloseButton_);
a=this.class_+"-buttons";
if(this.buttonEl_=Bi(j,a,this.getElement())[0]){
    this.buttons_=new Ik(this.getDomHelper());
    this.buttons_.decorate(this.buttonEl_)
}
else{
    this.buttonEl_=this.getDomHelper().createDom("div",a);
    this.getElement()[v](this.buttonEl_);
    this.buttons_&&this.buttons_.attachToElement(this.buttonEl_)
}
this.manageBackgroundDom_();
this.renderBackground_(xi(this.getElement())[dc]);
Qj(this.getElement(),k)
};
Q.enterDocument=function(){
Hk.superClass_.enterDocument[J](this);
this.focusHandler_=new yk(this.getDomHelper().getDocument());
if(this.draggable_&&!this.dragger_)this.dragger_=this.createDraggableTitleDom_();
this.getHandler().listen(this.titleCloseEl_,"click",this.onTitleCloseClick_).listen(this.focusHandler_,"focusin",this.onFocus_);
dj(this.getElement(),"dialog");
this.titleTextEl_.id!==""&&ej(this.getElement(),"labelledby",this.titleTextEl_.id)
};
Q.exitDocument=function(){
this.isVisible()&&this.setVisible(k);
this.focusHandler_.dispose();
this.focusHandler_=j;
if(this.dragger_){
    this.dragger_.dispose();
    this.dragger_=j
}
Hk.superClass_.exitDocument[J](this)
};
Q.setVisible=function(a){
if(a!=this.visible_){
    var b=this.getDomHelper().getDocument(),c=Ii(b)||p;
    this.isInDocument()||this.render(b[dc]);
    if(a){
        this.resizeBackground_();
        this.reposition();
        this.getHandler().listen(this.getElement(),"keydown",this.onKey_).listen(this.getElement(),"keypress",this.onKey_).listen(c,"resize",this.onResize_)
    }
    else this.getHandler().unlisten(this.getElement(),"keydown",this.onKey_).unlisten(this.getElement(),"keypress",this.onKey_).unlisten(c,"resize",this.onResize_);
    this.bgIframeEl_&&
    Qj(this.bgIframeEl_,a);
    this.bgEl_&&Qj(this.bgEl_,a);
    Qj(this.getElement(),a);
    a&&this[zc]();
    if(this.visible_=a)this.getHandler().listen(this.buttonEl_,"click",this.onButtonClick_);
    else{
        this.getHandler().unlisten(this.buttonEl_,"click",this.onButtonClick_);
        this[F]("afterhide");
        this.disposeOnHide_&&this.dispose()
    }
}
};
Q.isVisible=function(){
return this.visible_
};
Q.focus=function(){
try{
    this.getElement()[zc]()
}
catch(a){
}
if(this.getButtonSet()){
    var b=this.getButtonSet().getDefault();
    if(b)for(var c=this.getDomHelper().getDocument(),e=this.buttonEl_[xd]("button"),f=0,g;
    g=e[f];
    f++)if(g[N]==b){
        try{
            if(ng||lg){
                var h=c[K]("input");
                h[H].cssText="position:fixed;
width:0;
height:0;
left:0;
top:0;
";
                this.getElement()[v](h);
                h[zc]();
                this.getElement()[hc](h)
            }
            g[zc]()
        }
        catch(n){
        }
        break
    }
}
};
Q.resizeBackground_=function(){
this.bgIframeEl_&&Qj(this.bgIframeEl_,k);
this.bgEl_&&Qj(this.bgEl_,k);
var a=this.getDomHelper().getDocument(),b=Ii(a)||p,c=Gi(b||p);
b=r.max(a[dc].scrollWidth,c[z]);
a=r.max(a[dc][Cc],c[P]);
if(this.bgIframeEl_){
    Qj(this.bgIframeEl_,i);
    Lj(this.bgIframeEl_,b,a)
}
if(this.bgEl_){
    Qj(this.bgEl_,i);
    Lj(this.bgEl_,b,a)
}
if(this.draggable_){
    c=Mj(this.getElement());
    this.dragger_.limits=new vj(0,0,b-c[z],a-c[P])
}
};
Q.reposition=function(){
var a=this.getDomHelper().getDocument(),b=Ii(a)||p;
if(Bj(this.getElement())=="fixed")var c=a=0;
else{
    c=this.getDomHelper().getDocumentScroll();
    a=c.x;
    c=c.y
}
var e=Mj(this.getElement());
b=Gi(b||p);
a=r.max(a+b[z]/2-e[z]/2,0);
c=r.max(c+b[P]/2-e[P]/2,0);
Dj(this.getElement(),a,c)
};
Q.onTitleCloseClick_=function(){
if(this.hasTitleCloseButton_){
    var a=this.getButtonSet(),b=a&&a.getCancel();
    if(b){
        a=a.get(b);
        this[F](new Jk(b,a))&&this.setVisible(k)
    }
    else this.setVisible(k)
}
};
Q.setEscapeToCancel=function(a){
this.escapeToCancel_=a
};
Q.disposeInternal=function(){
Hk.superClass_.disposeInternal[J](this);
if(this.bgEl_){
    Ri(this.bgEl_);
    this.bgEl_=j
}
if(this.bgIframeEl_){
    Ri(this.bgIframeEl_);
    this.bgIframeEl_=j
}
this.tabCatcherEl_=this.buttonEl_=this.titleCloseEl_=j
};
Q.setButtonSet=function(a){
this.buttons_=a;
if(this.buttonEl_)if(this.buttons_)this.buttons_.attachToElement(this.buttonEl_);
else xa(this.buttonEl_,"")
};
Q.getButtonSet=function(){
return this.buttons_
};
Q.onButtonClick_=function(a){
if((a=this.findParentButton_(a[I]))&&!a[Xb]){
    a=a[N];
    var b=this.getButtonSet().get(a);
    this[F](new Jk(a,b))&&this.setVisible(k)
}
};
Q.findParentButton_=function(a){
for(a=a;
a!=j&&a!=this.buttonEl_;
){
    if(a[dd]=="BUTTON")return a;
    a=a[O]
}
return j
};
Q.onKey_=function(a){
var b=k,c=k,e=this.getButtonSet(),f=a[I];
if(a[Zc]=="keydown")if(this.escapeToCancel_&&a[Dc]==27){
    var g=e&&e.getCancel();
    f=f[dd]=="SELECT"&&!f[Xb];
    if(g&&!f){
        c=i;
        b=e.get(g);
        b=this[F](new Jk(g,b))
    }
    else f||(b=i)
}
else{
    if(a[Dc]==9&&a[cd]&&f==this.getElement())c=i
}
else if(a[Dc]==13){
    if(f[dd]=="BUTTON")g=f[N];
    else if(e){
        var h=e.getDefault(),n=h&&e.getButton(h);
        f=(f[dd]=="TEXTAREA"||f[dd]=="SELECT")&&!f[Xb];
        if(n&&!n[Xb]&&!f)g=h
    }
    if(g){
        c=i;
        b=this[F](new Jk(g,m(e.get(g))))
    }
}
if(b||c){
    a[Ob]();
    a[Sb]()
}
b&&this.setVisible(k)
};
Q.onResize_=function(){
this.resizeBackground_()
};
Q.onFocus_=function(a){
this.tabCatcherEl_==a[I]&&Dh(this.focusElement_,0,this)
};
Q.focusElement_=function(){
X&&this.getDomHelper().getDocument()[dc][zc]();
this.getElement()[zc]()
};
var Jk=function(a,b){
Oa(this,"dialogselect");
this.key=a;
this.caption=b
};
U(Jk,Ig);
var Ik=function(a){
this.dom_=a||yi();
qf[J](this)
};
U(Ik,qf);
Q=Ik[y];
Q.class_="goog-buttonset";
Q.defaultButton_=j;
Q.element_=j;
Q.cancelButton_=j;
Q.set=function(a,b,c,e){
qf[y].set[J](this,a,b);
if(c)this.defaultButton_=a;
if(e)this.cancelButton_=a;
return this
};
Q.addButton=function(a,b,c){
return this.set(a.key,a.caption,b,c)
};
Q.attachToElement=function(a){
this.element_=a;
this.render()
};
Q.render=function(){
if(this.element_){
    xa(this.element_,"");
    var a=yi(this.element_);
    pf(this,function(b,c){
        var e=a.createDom("button",{
name:c
        }
        ,b);
        if(c==this.defaultButton_)t(e,this.class_+"-default");
        this.element_[v](e)
    }
    ,this)
}
};
Q.decorate=function(a){
if(!(!a||a[zb]!=1)){
    this.element_=a;
    a=this.element_[xd]("button");
    for(var b=0,c,e,f;
    c=a[b];
    b++){
        e=c[N]||c.id;
        f=aj(c)||c[D];
        if(e){
            var g=b==0,h=c[N]=="cancel";
            this.set(e,f,g,h);
            g&&ui(c,this.class_+"-default")
        }
    }
}
};
Q.getDefault=function(){
return this.defaultButton_
};
Q.getCancel=function(){
return this.cancelButton_
};
Q.getButton=function(a){
for(var b=this.getAllButtons(),c=0,e;
e=b[c];
c++)if(e[N]==a||e.id==a)return e;
return j
};
Q.getAllButtons=function(){
return this.element_[xd]("BUTTON")
};
var Kk={
key:"ok",caption:"OK"
}
,Lk={
key:"cancel",caption:"Cancel"
}
,Mk={
key:"yes",caption:"Yes"
}
,Nk={
key:"no",caption:"No"
}
,Ok={
key:"save",caption:"Save"
}
,Pk={
key:"continue",caption:"Continue"
}
,Gk=function(){
return(new Ik).addButton(Kk,i).addButton(Lk,k,i)
};
(new Ik).addButton(Kk,i,i);
Gk();
(new Ik).addButton(Mk,i).addButton(Nk,k,i);
(new Ik).addButton(Mk).addButton(Nk,i).addButton(Lk,k,i);
(new Ik).addButton(Pk).addButton(Ok).addButton(Lk,i,i);
var Qk=function(){
this.handlers_={
};
this.successListeners_={
};
this.failureListeners_={
}
}
,Rk=j,Sk=function(){
Rk||(Rk=new Qk);
return Rk
};
Qk[y].fireEvent=function(a){
var b=j;
if(Od(a)){
    b=new Ig(a);
    var c=arguments[1];
    if(Od(c)){
        var e=2;
        for(c=c;
        c;
        ){
            var f=arguments[e++];
            b[c]=f;
            c=arguments[e++]
        }
    }
    else for(e in c)b[e]=c[e]
}
else if(a instanceof Ig)b=a;
this.processEvent_(b)
};
Qk[y].processEvent_=function(a){
var b=a[Zc],c=this.handlers_[b];
if(c){
    b=(c=c(a))?this.successListeners_[b]||[]:this.failureListeners_[b]||[];
    for(c=0;
    c<b[x];
    c++)b[c](a)
}
};
La(Qk[y],function(a,b){
this.handlers_[a]=b
}
);
var Tk=function(a,b){
var c=b||p;
if(a=="Parent"){
    this.stubName_="ParentStub"+fa(new Date);
    this.proxyName_="ChildStub"
}
else{
    this.stubName_="ChildStub";
    this.proxyName_=this.getParentProxyName_();
    this.otherWindow_=c.opener||c[ic];
    if(this.proxyName_&&!this.otherWindow_[this.proxyName_])for(var e=0;
    this.otherWindow_&&!this.otherWindow_[this.proxyName_]&&e<10;
    ){
        this.otherWindow_=this.otherWindow_[ic];
        e++
    }
    c.__topLevelProxy__=this
}
c[this.stubName_]=T(this.stub_,this);
this.type_=a
};
U(Tk,uh);
var Uk=function(a){
a=a||p;
return a.__topLevelProxy__
};
Q=Tk[y];
Q.setChildWindow=function(a,b){
this.otherWindow_=a;
this.iframe_=b
};
Oa(Q,j);
Q.getParentProxyName_=function(){
var a=new Sh(q[Rb][Rc]);
return a.getParameterValue("eventCallback")
};
Q.getStubName=function(){
return this.stubName_
};
Q.doEvent=function(a){
return this.proxyEvent_(a)
};
Q.proxyEvent_=function(a){
Oa(a,a[Zc]);
var b=this.iframe_?this.iframe_[pd]:j;
b=this.otherWindow_||b;
return this.proxyName_&&b&&b[this.proxyName_]?b[this.proxyName_](a):i
};
Q.stub_=function(a){
var b=new Ig(a[Zc],this),c;
for(c in a)c in b||(b[c]=a[c]);
return a=uh[y][F][J](this,b)
};
var Vk=function(){
};
U(Vk,uh);
Vk[y].setProxy=function(a){
this.proxy_=a
};
Ba(Vk[y],function(a){
this.proxy_.doEvent(a)&&uh[y][F][J](this,a)
}
);
var Wk=function(a){
Tk[J](this,"Parent",a||p)
};
U(Wk,Tk);
var Xk=j,Zk=function(a,b,c){
b=b||{
};
Sa(b,b.border||"OUTSET");
c=new Yk(c);
c.create_(a,b,j);
return c
}
,al=function(a,b,c,e){
b=b||{
};
Sa(b,b.border||"NONE");
c=zi(c);
e=new $k(e);
e.create_(a,b,c);
return e
};
Wk[y].create_=function(){
};
Wk[y].show=function(){
};
Wk[y].hide=function(){
};
Wk[y].dispose=function(){
};
var bl=function(a,b){
var c=b.serverbased?"widgets":"ui",e=new Sh((Xk?Xk:S.manifest?S.manifest.serverBase:"")+"/"+c+"/"+a);
c=new Sh(q[Rb][Rc]);
c.getParameterValue("js")?e.setParameterValue("js",c.getParameterValue("js")):e.setParameterValue("js","RAW");
b&&pf(b,function(f,g){
    f!=j&&e.setParameterValue(g,f)
}
);
return e
}
,cl=0;
Hd("createIframeComponent",al,void 0);
Hd("createIframeDialogComponent",Zk,void 0);
var $k=function(a){
Wk[J](this,a)
};
U($k,Wk);
Q=$k[y];
Q.iframe_=j;
Q.create_=function(a,b,c){
this.uri_=bl(a,b);
this.border_=b.border;
this.visible_=b.hide!="true";
this.mock_=b.mock;
this.x_=b.x||20;
this.y_=b.y||20;
this.width_=b[z]||600;
this.height_=b[P]||480;
this.maximize_=b.maximize=="true";
this.position_=b.position||"relative";
this.background_=b.background;
this.zIndex_=b.zIndex;
this.hl_=b.hl;
this.parentEl_=c;
var e;
a=this.width_;
b=this.height_;
c=this.border_;
var f=this.parentEl_,g="hosted-"+cl++ +"-"+fa(new Date),h=Z(g);
if(!h){
    f=new wi(f?xi(f):q);
    h=f.createDom("iframe",
    {
id:g
    }
    );
    xj(h,"display","block");
    xj(h,"backgroundColor","#FFF");
a:switch(c){
    case "NONE":e="0";
        break a;
    case "THIN":e="1px solid black";
        break a;
    case "OUTSET":e="2px outset black"
    }
    xj(h,"border",e);
    xj(h,"margin","0");
    xj(h,"padding","0");
    xj(h,"overflow","hidden");
    Lj(h,a,b)
}
e=h;
ra(e[H],this.position_);
if(this.zIndex_)e[H].zIndex=this.zIndex_;
if(this.background_){
    e.allowtransparency=i;
    e[H].backgroundColor="transparent"
}
this.hl_&&this.uri_.setParameterValue("hl",this.hl_);
if(!this.mock_){
    this.uri_.setParameterValue("eventCallback",
    this.getStubName());
    this.uri_.setParameterValue("js","RAW");
    this.uri_.makeUnique();
    e.src=this.uri_[db]();
    e.id=Be()
}
this.enterDocument_(e);
if(this.mock_){
    new Tk("Child",e[pd]);
    e[pd].__topLevelProxy__.proxyName_=this.getStubName()
}
this.setChildWindow(e[pd],e)
};
Q.enterDocument_=function(a){
this.iframe_=a;
if(this.parentEl_){
    this.parentEl_[v](a);
    this.updateSize()
}
else{
    ra(a[H],"absolute");
    q[dc][v](a)
}
if(!this.visible_)$a(a[H],"hidden");
this.updateSize();
if(p[Ad][a.id])if(p[Ad][a.id][Rb]!=a.src)p[Ad][a.id].location=a.src
};
Q.updateSize=function(){
var a=this.sizingEl_||this.parentEl_;
if(a&&this.maximize_){
    var b=Mj(a);
    Lj(this.iframe_,b);
    this.position_=="absolute"&&Kj(this.iframe_,Hj(a))
}
};
Q.show=function(){
this.visible_=i;
this.updateSize();
this.doEvent("PRESHOW");
var a=this;
S[yb](function(){
    Wa(a.iframe_[H],"block");
    $a(a.iframe_[H],"visible");
    a.doEvent("SHOW")
}
,5)
};
Q.hide=function(){
this.visible_=k;
if(this.position_=="absolute")$a(this.iframe_[H],"hidden");
else Wa(this.iframe_[H],"none")
};
Q.dispose=function(){
if(this.iframe_){
    this.iframe_[O][hc](this.iframe_);
    this.iframe_=j
}
Wk[y].dispose[J](this)
};
var Yk=function(a){
Wk[J](this,a)
};
U(Yk,$k);
Yk[y].enterDocument_=function(a){
mg&&ui(q[dc],"background");
var b=new Hk;
b.getContentElement()[v](a);
b.setButtonSet(new Ik);
b.setVisible(this.visible_);
this.dialog_=b;
this.iframe_=a
};
Yk[y].show=function(){
this.dialog_.setVisible(i)
};
Yk[y].hide=function(){
this.dialog_.setVisible(k)
};
Yk[y].dispose=function(){
this.dialog_.dispose();
vi(q[dc],"background");
this.iframe_=this.dialog_=j;
$k[y].dispose[J](this)
};
var dl=function(){
this.creatorMap_={
}
};
var el=dl[y].creatorMap_=j;
Q=dl[y];
Q.getCreator_=function(a){
return this.creatorMap_[a]
};
Q.create=function(a,b,c){
var e=this.getCreator_(a);
if(e){
    if(b)b=zi(b);
    return e(b,c,a)
}
};
Q.createAsFullPage=function(a){
var b=this.getCreator_(a);
if(b){
    var c={
    }
    ,e=(new Sh(q[Rb][Rc])).getQueryData();
    pf(e,function(f,g){
        c[g]=f
    }
    );
    e=new Tk("Child");
    a=b(q[dc],c,a);
    a.setProxy&&a.setProxy(e)
}
};
Q.buildUi=function(a){
a=a||q[dc];
var b=a[Ac]("g:type");
if(b){
    for(var c={
    }
    ,e=a[hd],f=0;
    f<e[x];
    f++){
        var g=e[f][N];
        if(be(g,"g:"))c[g[Sc](2)]=e[f][D]
    }
    this.create(b,a,c)
}
b=a[bd][x];
for(f=0;
f<b;
f++){
    c=a[bd][f];
    c[zb]==1&&this.buildUi(c)
}
};
Q.fireHostedEvent=function(a){
var b=Uk();
if(b){
    if(Od(a))a=new Ig(a);
    return b.doEvent(a)
}
else return i
};
var fl;
el||(el=new dl);
fl=el;
Hd("Xuit",fl,void 0);
dl[y].buildUi=dl[y].buildUi;
dl[y].create=dl[y].create;
dl[y].createAsFullPage=dl[y].createAsFullPage;
dl[y].fireHostedEvent=dl[y].fireHostedEvent;
Wk[y].hide=Wk[y].hide;
Wk[y].show=Wk[y].show;
Wk[y].dispose=Wk[y].dispose;
var gl=function(a){
a&&this.setSource_(a)
}
,hl={
}
,il=function(a){
var b=new gl;
b.value_=a;
return b
};
gl[y].setSource_=function(a){
this.src_=a;
if(a=="TRUE"||a=="true")this.value_=i;
else if(a=="FALSE"||a=="false")this.value_=k;
else if(be(a,'"')&&ce(a,'"'))this.value_=a[Sc](1,a[x]-1);
else if(be(a,"'")&&ce(a,"'"))this.value_=a[Sc](1,a[x]-1);
else if(ia(a))d(l("Invalid static expression: "+a));
else this.value_=fa(a)
};
gl[y].getValue=function(){
return this.value_
};
gl[y].getDataDeps=function(){
return[]
};
var jl=function(a){
this.setSource_(a)
}
,kl={
}
,ll=function(a){
var b=kl[a];
if(b==j){
    b=new jl(a);
    kl[a]=b
}
return b
};
Q=jl[y];
Q.setSource_=function(a){
this.src_=a;
this.dataDeps_=[];
if(this.tryMatchAndOr_("||"))this.evaluator_=this.evaluateOr_;
else if(this.tryMatchAndOr_("and"))this.evaluator_=this.evaluateAnd_;
else if(this.tryMatchOp_("!="))this.evaluator_=this.evaluateNotEquals_;
else if(this.tryMatchOp_("="))this.evaluator_=this.evaluateEquals_;
else if(this.tryMatchOp_("<"))this.evaluator_=this.evaluateLessThan_;
else if(this.tryMatchOp_(">"))this.evaluator_=this.evaluateGreaterThan_;
else{
    this.expr_=this.linkToExpr_(a);
    this.evaluator_=this.getUnaryValue_
}
};
Q.tryMatchOp_=function(a){
var b=this.src_,c=b[E](a);
if(c!=-1){
    this.op_=a;
    this.firstExpr_=this.linkToExpr_(je(b[Sc](0,c)));
    this.secondExpr_=this.linkToExpr_(je(b[Sc](c+a[x])));
    return i
}
else return k
};
Q.tryMatchAndOr_=function(a){
var b=this.src_,c=b[E](a);
if(c!=-1){
    this.op_=a;
    this.firstExpr_=ll(je(b[Sc](0,c)));
    this.secondExpr_=ll(je(b[Sc](c+a[x])));
    this.dataDeps_=this.dataDeps_[Kb](this.firstExpr_.getDataDeps());
    this.dataDeps_=this.dataDeps_[Kb](this.secondExpr_.getDataDeps());
    return i
}
else return k
};
Q.linkToExpr_=function(a){
var b=a[Sc](0,1),c=a[zd]();
if("0123456789'\""[E](b)==-1&&c!="true"&&c!="false"){
    a=W(a);
    this.dataDeps_[w](a);
    return a
}
else{
    a=a;
    b=hl[a];
    if(b==j){
        b=new gl(a);
        hl[a]=b
    }
    return a=b
}
};
Q.getUnaryValue_=function(a){
return this.expr_.getValue(a)?i:k
};
Q.evaluateEquals_=function(a){
return this.firstExpr_.getValue(a)==this.secondExpr_.getValue(a)
};
Q.evaluateNotEquals_=function(a){
return this.firstExpr_.getValue(a)!=this.secondExpr_.getValue(a)
};
Q.evaluateLessThan_=function(a){
return this.firstExpr_.getValue(a)<this.secondExpr_.getValue(a)
};
Q.evaluateGreaterThan_=function(a){
return this.firstExpr_.getValue(a)>this.secondExpr_.getValue(a)
};
Q.evaluateOr_=function(a){
return this.firstExpr_.getValue(a)||this.secondExpr_.getValue(a)
};
Q.evaluateAnd_=function(a){
return this.firstExpr_.getValue(a)&&this.secondExpr_.getValue(a)
};
Q.getValue=function(a){
return this.evaluator_(a)
};
Q.getDataDeps=function(){
return this.dataDeps_
};
var $={
};
$.getData=function(a,b){
return W(a).getValue(b)
};
$.setData=function(a,b,c){
a=W(a);
a.getParent()?a.getParent().getNode(c,i).setChildNode(a.getLast(),b):a.getNode(c).set(b)
};
$.getNode=function(a,b){
return W(a).getNode(b)
};
$.getNodes=function(a,b){
return W(a).getNodes(b)
};
$.dumpData=function(a,b){
var c=Od(a)?$.getNode(a):a;
b=b||0;
if(b>20)return"";
var e="                 ",f="";
f=f+e[Sc](0,b)+c.getDataName()+":";
var g=c.getChildNodes();
c=c.get();
if(g.getCount()==0&&(!c||!c.getCount))f+=c;
else{
    f+="{
\n";
    for(c=0;
    c<g.getCount();
    c++)f=f+$.dumpData(g.getByIndex(c),b+1)+"\n";
    f=f+e[Sc](0,b)+"
}
"
}
return f
};
var ml=/^([a-z0-9%&\'\+\-\/=\?_.]+|"[a-z0-9%\'\+\-\/=\?_.]+")\@(([a-z0-9\-])+\.)+([a-z0-9]{
2,6
}
)$/i,nl=/^([a-z0-9%&\'\+\-\/=\?_.]+|"[a-z0-9%\'\+\-\/=\?_.]+")\@(([a-z0-9\-\u00a0-\ufff7])+\.)+([a-z0-9\u00a0-\ufff7]{
2,6
}
)$/i,ol=function(a){
var b=$[C]("$ContactManagerConfig/AllowIdn");
a=je(a)[zd]();
if(b)return nl[lb](a);
return ml[lb](a)
}
,pl={
email:ol
};
var rl=function(a,b,c,e,f){
if(a){
this.input_=a;
if(this.imageLoc_=b||a[Ac]("icon")){
this.div_=Ki("div",{
className:this.input_[ob]
}
);
t(this.input_,"inner");
this.img_=q[K]("img");
this.img_.src=this.imageLoc_;
this.img_[H].verticalAlign="bottom";
this.div_[v](this.img_);
if(this.img_[sc]!="complete"){
Wa(this.img_[H],"none");
Y(this.img_,"load",this.imageLoaded_,k,this)
}
if(X)this.img_[H].verticalAlign="top";
if(e&&f){
t(this.img_,e);
xj(this.img_,"background-image","url("+f+")")
}
a[O][pb](this.div_,a);
this.div_[v](a);
Sa(this.input_[H],"0px");
this.input_[H].padding="0px";
this.input_[H].paddingLeft="4px";
this.div_[H].verticalAlign="top";
this.input_[H].whiteSpace="nowrap";
ta(this.input_[H],"80%");
Va(this.div_[H],"hidden")
}
(this.defaultText_=c||a[Ac]("defaultText"))&&ql(this.input_,this.defaultText_)
}
};
rl[y].imageLoaded_=function(){
Wa(this.img_[H],"inline")
};
var sl=function(a,b){
this.el_=a;
if(a!=j){
if(this.enabledExpr_=b?ll(b):j){
var c=T(this.syncEnabledState_,this);
pf(this.enabledExpr_.getDataDeps(),function(g){
V().addListener(c,g.src_)
}
);
this.syncEnabledState_()
}
if(X){
var e=Mj(a);
ta(a[H],m(e[z]*0.77)+"px");
e=fa(a[Qc].paddingTop[Fb]("px")[0]);
var f=fa(a[Qc].paddingBottom[Fb]("px")[0]);
a[H].paddingTop=m(e+2)+"px";
e=f>=2?f-2:0;
a[H].paddingBottom=m(e)+"px"
}
Y(a,"mousedown",T(this.preSubmit,this));
Y(a,"mouseup",T(this.preSubmitCancel,this));
Y(a,"mouseout",
T(this.maskPreSubmit,this));
Y(a,"mouseover",T(this.unmaskPreSubmit,this));
Y(a,"click",T(this.preSubmitCancel,this))
}
};
Q=sl[y];
Q.preSubmit=function(a){
ui(a[I],"presubmit");
a[I].preSubmitActive_=i
};
Q.preSubmitCancel=function(a){
vi(a[I],"presubmit");
a[I].preSubmitActive_=k
};
Q.maskPreSubmit=function(a){
vi(a[I],"presubmit")
};
Q.unmaskPreSubmit=function(a){
a[I].preSubmitActive_&&ui(a[I],"presubmit")
};
Q.syncEnabledState_=function(){
if(this.enabledExpr_)Aa(this.el_,!this.enabledExpr_.getValue())
};
var tl=function(a,b){
if(a){
$a(a[H],"");
var c=a[z];
if(c>b)ta(a[H],b+"px")
}
}
,ul=function(a,b,c,e){
a=a[Fb](".");
for(var f=e=e||S,g=a[x],h=0;
h<g-1;
h++){
f[a[h]]||(f[a[h]]={
}
);
f=f[a[h]]
}
f[a[g-1]]=b;
if(c)e[c]=b
}
,ql=function(a,b){
if(a[D]==""||a[D]==b||a[D]==a.defaultText){
a.defaulted=i;
za(a,b);
ui(a,"input-default")
}
a.defaultText=b;
Y(a,"focus",function(){
if(a.defaulted){
za(a,"");
vi(a,"input-default");
a.defaulted=k
}
}
);
Y(a,"blur",T(vl,j,a));
Y(q,"keypress",function(c){
c[I]==a&&c[Dc]==27&&c[Ob]()
}
,i)
}
,vl=function(a){
if(a[D]==
""&&!a.defaulted){
a.defaulted=i;
za(a,a.defaultText);
ui(a,"input-default")
}
}
,wl=function(a){
if(!a.defaulted){
za(a,"");
a[Mb]();
vl(a)
}
}
,xl=function(a,b){
b=b<0?0:b;
Xa(a[H],b+"px");
a.__lastHeight=b
}
,yl=function(a,b){
b=b<0?0:b;
ta(a[H],b+"px");
a.__lastWidth=b
}
,Al=function(a){
return zl(a,"paddingLeft")+zl(a,"paddingRight")+zl(a,"marginLeft")+zl(a,"marginRight")+zl(a,"borderLeftWidth")+zl(a,"borderRightWidth")
}
,Bl=function(a){
return zl(a,"paddingTop")+zl(a,"paddingBottom")+zl(a,"marginTop")+zl(a,"marginBottom")+
zl(a,"borderTopWidth")+zl(a,"borderBottomWidth")
}
,zl=function(a,b){
var c=xi(a),e;
if(c[fd]&&c[fd][$b])if(c=c[fd][$b](a,""))e=c[b];
e||(e=a[Qc]?a[Qc][b]:a[H][b]);
if(ce(e,"px")){
e=fa(e[Sc](0,e[x]-2));
if(e<-10)e=0;
return e
}
else return 0
};
var Cl=function(a,b){
this.el_=zi(a);
this.dataExpr_=W(b);
V().addListener(T(this.dataChanged_,this),b);
Y(this.el_,"click",T(this.elementClicked_,this),k,this);
var c=this.dataExpr_.getValue();
if(c)va(this.el_,c)
};
Cl[y].dataChanged_=function(){
if(!this.inElementChange_){
var a=this.dataExpr_.getValue();
this.inDataChange_=i;
va(this.el_,a!=0);
this.inDataChange_=k
}
};
Cl[y].elementClicked_=function(){
if(!this.inDataChange_){
var a=this.el_[wb];
this.inElementChange_=i;
$[u](this.dataExpr_.getSource(),a);
this.inElementChange_=k
}
};
var Dl=function(a,b,c,e,f,g,h,n){
this.el_=zi(a);
this.dataExpr_=W(b);
this.continuous_=c;
this.defaultText_=e||this.el_[Ac]("defaultText");
this.maxChars_=f;
this.pathToSetOnChange_=g||j;
this.autoexpandIncrement_=da(h||"0",10);
if(this.autoexpandIncrement_>0)Va(this.el_[H],"hidden");
this.validator_=pl[n]||j;
if(this.maxChars_)this.el_.maxLength=this.maxChars_;
V().addListener(T(this.dataChanged_,this),b);
Y(this.el_,"change",this.elementChanged_,k,this);
Y(this.el_,"keyup",this.elementChanged_,k,this);
if(a=
this.dataExpr_.getValue()){
za(this.el_,a);
this.expandIfApplicable_()
}
if(this.defaultText_){
Y(this.el_,"blur",this.checkForDefault_,k,this);
Y(this.el_,"focus",this.onFocus_,k,this);
this.checkForDefault_()
}
};
Q=Dl[y];
Q.dataChanged_=function(){
if(!this.inElementChange_){
var a=this.dataExpr_.getValue();
this.inDataChange_=i;
za(this.el_,a?a:"");
this.expandIfApplicable_();
this.defaulted_=this.inDataChange_=k;
this.defaultText_&&this.checkForDefault_()
}
};
Q.elementChanged_=function(){
if(!this.inDataChange_){
this.expandIfApplicable_();
var a=this.el_[D]||j;
this.inElementChange_=i;
var b=this.dataExpr_.getParent().getNode(j,i);
b.setChildNode(this.dataExpr_.getLast(),a);
this.inElementChange_=k;
this.pathToSetOnChange_&&$[u](this.pathToSetOnChange_,i);
if(this.validator_)this.validator_(this.el_[D])?vi(this.el_,"cmgr-input-invalid"):ui(this.el_,"cmgr-input-invalid")
}
};
Q.expandIfApplicable_=function(){
if(this.autoexpandIncrement_>0&&this.el_[Hc]<this.el_[Cc])Xa(this.el_[H],this.el_[Cc]+this.autoexpandIncrement_+"px")
};
Q.checkForDefault_=function(){
if(this.el_[D]==""&&!this.defaulted_){
this.defaulted_=i;
ui(this.el_,"input-default");
vi(this.el_,"cmgr-input-invalid");
za(this.el_,this.defaultText_)
}
else{
vi(this.el_,"input-default");
this.defaulted_=k
}
};
Q.onFocus_=function(){
if(this.defaulted_){
za(this.el_,"");
vi(this.el_,"input-default");
this.defaulted_=k
}
};
var El=function(a){
this.el_=a;
this.stableTime_=200;
this.pauseTime_=1E3;
this.handleValueChangeFunction_=T(this.handleValueChange_,this);
Y(a,["input","propertychange"],this.handleValueChange_,k,this);
Y(a,"keypress",this.handleKeyPress_,k,this);
Y(a,"keydown",this.handleKeyDown_,k,this);
var b=["focus","click","blur"];
Y(a,b,this.handlePassThrough_,k,this)
};
mf(El[y],uh[y]);
Q=El[y];
Q.setPauseTime=function(a){
this.pauseTime_=a
};
Q.handleKeyPress_=function(a){
S[yb](this.handleValueChangeFunction_,0);
this[F](a)||a[Sb]()
};
Q.handleKeyDown_=function(a){
var b=a[Dc],c=j;
if(b==40)c="DOWN_ARROW";
else if(b==38)c="UP_ARROW";
else if(b==13)c="ENTER";
else if(b==27)c="ESCAPE";
else if(b==9)c="TAB";
if(X&&(b==8||b==46))S[yb](this.handleValueChangeFunction_,0);
if(c)(b=this[F](c))||a[Sb]()
};
Q.handlePassThrough_=function(a){
this[F](a)
};
Q.handleValueChange_=function(){
var a=this.el_.defaulted?"":this.el_[D];
if(a!=this.lastValue_){
this.dispatchValueEvent_("VALUE",a);
this.stableTimer_&&S[qb](this.stableTimer_);
this.stableTimer_=S[yb](T(this.checkSameValue_,this,"STABLE_VALUE",a),this.stableTime_);
this.pauseTimer_&&S[qb](this.pauseTimer_);
this.pauseTimer_=S[yb](T(this.checkSameValue_,this,"PAUSED_VALUE",a),this.pauseTime_);
this.lastValue_=a
}
};
Q.checkSameValue_=function(a,b){
var c=this.el_.defaulted?"":this.el_[D];
c==b&&this.dispatchValueEvent_(a,b)
};
Q.dispatchValueEvent_=function(a,b){
var c=new Ig(a);
za(c,b);
this[F](c)
};
var Fl=function(a,b){
this.el_=Z(a);
this.dataExpr_=W(b);
this.boundPropertyName_=this.dataExpr_.getLast();
this.setupListeners_(b);
var c=this.dataExpr_.getValue();
if(c&&this.el_)va(this.el_,c)
};
Fl[y].setupListeners_=function(){
Y(this.el_,"click",T(this.elementClicked_,this),k,this)
};
Fl[y].elementClicked_=function(){
var a=this.dataExpr_.getParent().getParent().getNode(j,i);
a=a.get();
for(var b=0;
b<a[x];
b++)a[b].getChildNode(this.boundPropertyName_).set(k);
$[u](this.dataExpr_.getSource(),i)
};
var Gl=function(a,b,c){
this.el_=zi(a);
this.dataExpr_=W(b);
a=this.dataExpr_.getValue();
if(c){
this.dataType_=c;
pf(c.getValues(),function(f,g){
var h=q[K]("option");
za(h,g);
ua(h,f);
this.el_[tc][this.el_[tc].length++]=h
}
)
}
for(c=0;
c<this.el_[tc][x];
c++){
var e=this.el_[tc][c];
if(a==e[D])ya(e,i)
}
V().addListener(T(this.dataChanged_,this),b);
Y(this.el_,"change",this.elementChanged_,k,this);
Y(this.el_,"keyup",this.elementChanged_,k,this)
};
Gl[y].dataChanged_=function(){
if(!this.inElementChange_){
var a=this.dataExpr_.getValue();
this.inDataChange_=i;
za(this.el_,a?a:"");
this.inDataChange_=k
}
};
Gl[y].elementChanged_=function(){
if(!this.inDataChange_){
var a=this.el_[D]||j;
this.inElementChange_=i;
$[u](this.dataExpr_.getSource(),a);
this.inElementChange_=k
}
};
var Hl=function(a,b,c,e){
this.el_=zi(a);
this.dataExpr_=W(b);
var f=this.dataExpr_.getValue();
this.addOptions_(c);
for(c=0;
c<this.el_[tc][x];
c++){
var g=this.el_[tc][c];
if(f==g[D])ya(g,i)
}
Gl[J](this,a,b,e)
};
U(Hl,Gl);
Hl[y].addOptions_=function(a){
var b,c;
if(a=="day"){
b=1;
c=31
}
if(a=="year"){
b=1900;
c=(new Date)[Fc]()
}
for(a=b;
a<=c;
a++){
b=q[K]("option");
za(b,a);
ua(b,""+a);
this.el_[tc][this.el_[tc].length++]=b
}
};
var Jl,Kl,Ml=function(){
Ll()
}
,Ll=function(a){
a=a||q[Dd];
if(Jl){
var b=Gi(p),c=b[P]-Kl[P];
b=b[z]-Kl[z];
if(b>0)b=0;
Nl(a,b,c)
}
Ol(a);
Jl=i;
Kl=Gi(p)
}
,Pl=function(a){
return a[zb]==1&&(a[Ac]("maximize")=="true"||a[Ac]("maximize")=="compatible"&&(mg||lg))
}
,Nl=function(a,b,c){
for(var e=a[Ec];
e;
e=e[md])Nl(e,b,c);
if(Pl(a)){
a.__lastWidth&&yl(a,a.__lastWidth+b);
a.__lastHeight&&xl(a,a.__lastHeight+c)
}
}
,Ol=function(a){
if(Pl(a)&&a[bc]!="TR"){
var b,c;
if(a[O][bc]=="BODY"){
c=Gi(p);
b=c[z];
c=c[P];
Va(a[O][H],"hidden")
}
else{
c=
a[O];
b=a[O][Jb]-Al(c);
if(mg)b-=Al(a);
var e=a[O][td];
if(ng&&a[O][bc]=="TD"&&a[O][O].__lastHeight)e=a[O][O].__lastHeight;
c=e-Bl(c)
}
Al(a);
a[bc]!="TABLE"&&yl(a,b);
xl(a,c);
a[td]>c&&xl(a,2*c-a[td]);
if(a[bc]=="TABLE"){
b=j;
e=0;
var f;
for(f=0;
f<a[Wc][x];
f++){
var g=a[Wc][f];
if(g[Ac]("maximize")=="true"){
b=g;
Xa(b[H],"100%")
}
}
if(b){
for(f=0;
f<a[Wc][x];
f++){
g=a[Wc][f];
if(g!=b){
g=ng&&g[Ec]?g[Ec][td]:g[td];
e+=g
}
}
xl(b,c-e-2);
ta(b[H],"")
}
}
}
for(a=a[Ec];
a;
a=a[md])Ol(a)
};
var Ql=function(){
this.messages_=[];
this.lastMessage_={
};
V().addDataSource(new wk(this.lastMessage_,"LastMessage"))
}
,Rl;
Ql[y].add=function(a,b,c,e){
var f=a[x]<150,g=i;
if(f){
f=new Ig("NOTIFY_USER");
f.message=a;
f.level=b;
f.url=c;
f.link=e;
g=Uk().doEvent(f)
}
g&&this.displayMessage(a,b,c,e)
};
Ql[y].displayMessage=function(a,b,c,e){
b=b||"INFO";
var f={
Message:a,Level:b
};
this.messages_[w](f);
this.lastMessage_.Message=a;
this.lastMessage_.Level=b;
this.lastMessage_.Url=c;
this.lastMessage_.Link=e;
V().fireDataChange("$LastMessage")
};
Ra(Ql[y],function(){
var a=new Ig("CLEAR_NOTIFICATIONS");
Uk().doEvent(a)&&this.clearMessage()
}
);
Ql[y].clearMessage=function(){
var a={
Message:j
};
this.messages_[w](a);
this.lastMessage_.Message=j;
this.lastMessage_.Level=j;
this.lastMessage_.Url=j;
this.lastMessage_.Link=j;
V().addDataSource(new wk(this.lastMessage_,"LastMessage"));
V().fireDataChange("$LastMessage")
};
var Sl=function(){
if(Rl==j)Rl=new Ql;
return Rl
};
var Tl=function(a,b){
this.messageElId_=a;
this.dataPath_=b||"$LastMessage";
this.messageExpr_=W(this.dataPath_+"/Message");
this.typeExpr_=W(this.dataPath_+"/Level");
this.urlExpr_=W(this.dataPath_+"/Url");
this.linkExpr_=W(this.dataPath_+"/Link");
V().addListener(T(this.invalidate_,this),this.dataPath_+"/...");
this.invalid_=k
};
Tl[y].invalidate_=function(){
this.invalid_||S[yb](T(this.render_,this),0);
this.invalid_=i
};
Tl[y].render_=function(){
if(this.invalid_){
var a=Z(this.messageElId_);
if(a){
var b=this.messageExpr_.getValue();
if(b==j){
vi(a,"error");
vi(a,"info");
xa(a,"")
}
else{
var c=this.typeExpr_.getValue();
if(c=="INFO"){
ui(a,"info");
vi(a,"error")
}
else{
ui(a,"error");
vi(a,"info")
}
ui(a,"hilite");
if(b[x]<150){
var e=this.urlExpr_.getValue();
c=this.linkExpr_.getValue();
if(e&&c){
e=Ki("a",{
href:e,target:"_blank"
}
);
xa(e,se(c));
xa(a,"");
a[v](q[Nb](se(b)+" "));
a[v](e)
}
else xa(a,se(b))
}
else{
var f=Ki("div",{
style:"display:none;
position:absolute;
background-color:white;
padding:8px;
border:1px dashed #AAA;
text-decoration: none;
z-index: 100;
"
}
);
xa(f,se(b)[B](/\n/g,"<br/>"));
b=Ki("a",{
href:"#"
}
);
Y(b,"click",function(){
Wa(f[H],f[H][ld]=="block"?"none":"block")
}
);
xa(b,"Details");
xa(a,"");
a[v](q[Nb]("Operation failed. Please try again in a moment. "));
a[v](b);
a[v](f);
b=Hj(a);
a=Mj(a);
c=Mj(f);
Dj(f,b.x+a[z]-c[z],b.y+a[P])
}
S[yb](T(this.postRender_,this),1E3)
}
}
this.invalid_=k
}
};
Tl[y].postRender_=function(){
var a=Z(this.messageElId_);
a&&vi(a,"hilite")
};
var Ul=function(){
this.baseUri_="..";
this.resourceTypeUris_={
};
this.widgetFamilyUris_={
};
this.widgetFamilyResourceUris_={
};
this.inlineWidgets_={
};
this.hostedWidgets_={
};
this.widgetDialogs_={
}
}
,Wl=function(){
Vl||(Vl=new Ul);
return Vl
}
,Vl=j;
Q=Ul[y];
Q.setServerBase=function(a,b,c){
a=new Sh(a);
if(b&&c){
this.widgetFamilyResourceUris_[b]||(this.widgetFamilyResourceUris_[b]={
}
);
this.widgetFamilyResourceUris_[b][c]=a
}
else if(b)this.widgetFamilyUris_[b]=a;
else if(c)this.resourceTypeUris_[c]=a;
else this.baseUri_=a
};
Q.getServerBase=function(a,b){
return this.widgetFamilyResourceUris_[a]&&this.widgetFamilyResourceUris_[a][b]?this.widgetFamilyResourceUris_[a][b]:this.widgetFamilyUris_[a]?this.widgetFamilyUris_[a]:this.resourceTypeUris_[b]?this.resourceTypeUris_[b]:this.baseUri_
};
Q.registerInline=function(a){
this.inlineWidgets_[a.getId()]=a
};
Q.attachWidget=function(a,b,c){
var e=this.inlineWidgets_[a];
if(e&&e.attach){
e.attach(b,c);
return i
}
if((a=this.hostedWidgets_[a])&&a.attach){
a.attach(b,c);
return i
}
return k
};
Q.displayIframe=function(a,b,c,e){
if((a=this.inlineWidgets_[a])&&a.displayIframe){
a.displayIframe(b,c,e);
return i
}
return k
};
var Xl=0;
Q=Ul[y];
Q.createIframeDialog=function(a,b,c,e,f){
sg&&mg&&ui(q[dc],"background");
var g=f||p;
f=yi(g[Ab][Dd]);
b=this.createIframeElement_(a,b,f);
c=this.createWidgetUrl_(a,c,e,g);
if(!X)b.src=c;
e=new Hk(ba,k,f);
e.getContentElement()[v](b);
e.setButtonSet(new Ik);
ui(e.getDialogElement(),"fcs-iframedlg");
e.setVisible(i);
e.setEscapeToCancel(k);
if(X)b.src=c;
this.widgetDialogs_[a]=e;
return b[pd]
};
Q.createIframeElement_=function(a,b,c){
a=a+"-iframe";
var e=c.$(a);
if(!e){
e=c.createDom("iframe",{
id:a,scrolling:"no",frameborder:"0"
}
);
xj(e,"display","block");
xj(e,"backgroundColor","#FFF");
xj(e,"border","1px solid #555");
Lj(e,b[z],b[P])
}
return e
};
Q.createWidgetUrl_=function(a,b,c,e){
var f=new Sh(this.getServerBase()+"/ui/"+a);
if(c){
a="UiWidgetCallback"+Xl++;
e=e||p;
e[a]=c;
f.setParameterValue("done",a)
}
f.setParameterValue("js","RAW");
f.setParameterValue("pop","TRUE");
b&&pf(b,function(g,h){
g!=j&&f.setParameterValue(h,g)
}
);
return f
};
Q.eraseIframeDialog=function(a){
var b=this.widgetDialogs_[a];
if(b){
b.dispose();
vi(q[dc],"background")
}
delete this.widgetDialogs_[a]
};
Q.hideIframeDialog=function(a){
(a=this.widgetDialogs_[a])&&a.setVisible(k)
};
Q.sendToWidget=function(a,b,c){
c=c||p;
c=yi(c[Ab][Dd]);
a=this.inlineWidgets_[a];
(a=c.getElement(a.getId()+"-iframe"))&&a[pd].UI_receive&&a[pd].UI_receive(b)
};
Q.attachAndDisplayAllWidgets=function(a){
a=a||q[Dd];
for(var b=a[Ec];
b;
b=b[md])this.attachAndDisplayAllWidgets(b);
if(a[Ac])if(b=a[Ac]("gtype")){
for(var c={
}
,e=0;
e<a[hd][x];
e++){
var f=a[hd][e];
c[f[N]]=f[D]
}
this.attachWidget(b,a,c)
}
};
p.UI_setServerBase=function(a,b,c){
Wl().setServerBase(a,b,c)
};
p.UI_getServerBase=function(){
Wl()
};
p.UI_attachAndDisplayAllWidgets=function(a){
Wl().attachAndDisplayAllWidgets(a)
};
p.UI_attachWidget=function(a,b,c){
Wl().attachWidget(a,b,c)
};
p.UI_displayInline=function(){
Wl()
};
p.UI_displayIframe=function(a,b){
Wl().displayIframe(a,b)
};
var Zl=function(a,b){
if(b&&!a)d(l("Can't create document with namespace and no root tag"));
if(q.implementation&&q.implementation.createDocument)return q.implementation.createDocument(b||"",a||"",j);
else if(typeof ActiveXObject!="undefined"){
var c=Yl();
if(c){
if(a)c[v](c.createNode(1,a,b||""));
return c
}
}
d(l("Your browser does not support creating new documents"))
}
,Yl=function(){
var a=new ActiveXObject("MSXML2.DOMDocument");
if(a){
a.resolveExternals=k;
a.validateOnParse=k;
try{
a.setProperty("ProhibitDTD",
i);
a.setProperty("MaxXMLSize",2048);
a.setProperty("MaxElementDepth",256)
}
catch(b){
}
}
return a
};
var $l=function(){
};
Q=$l[y];
Q.startElement=function(){
};
Q.endElement=function(){
};
Q.chars=function(){
};
Q.startOutput=function(){
};
Q.endOutput=function(){
};
var am=function(a,b){
this.setSource_(a,b)
}
,bm=function(a,b){
if(a[E]("{
{
    ")==-1||a[E]("function(")!=-1)return il(a);
else if(be(a,"{
        {
            ")&&ce(a,"
        }
    }
    ")){
var c=W(a[Sc](2,a[x]-2));
if(b==1){
c=new Wf(c.getSource());
c.isJsLiteral_=i
}
c.getDataDeps=function(){
return[c]
};
return c
}
else return new am(a,b)
};
am[y].setSource_=function(a,b){
this.src_=a;
this.parts_=[];
this.dataDeps_=[];
if(this.src_[E]("{
        {
            ")==-1)this.parts_[w](il(this.src_));
else for(var c=this.src_[Fb]("{
                {
                    "),e=0;
e<c[x];
e++){
var f=c[e];
if(f[x]>0){
var g=f[E]("
                }
            }
            ");
if(g==-1)this.parts_[w](il(f));
else{
var h=f[Sc](0,g);
if(b==1){
h=new Wf(h);
h.isJsLiteral_=i
}
else h=W(h);
this.parts_[w](h);
this.dataDeps_[w](h);
if(g<f[x]-1){
f=f[Sc](g+2);
this.parts_[w](il(f))
}
}
}
}
};
am[y].getValue=function(a){
for(var b=this.parts_[x],c=[],e=0;
e<b;
e++){
var f=this.parts_[e].getValue(a);
if(this.parts_[e].isJsLiteral_)if(f==j)f="null";
else if(Od(f)){
f=f;
f=m(f);
if(f.quote)f=f.quote();
else{
for(var g=['"'],h=0;
h<f[x];
h++){
var n=f[Lb](h),o=n[Jc](0),s=g,A=h+1,G;
if(!(G=xe[n])){
if(o>31&&o<127)n=n;
else{
n=n;
if(n in ye)n=ye[n];
else if(n in xe)n=ye[n]=xe[n];
else{
o=n;
G=n[Jc](0);
if(G>31&&G<127)o=n;
else{
if(G<256){
o="\\x";
if(G<16||G>256)o+="0"
}
else{
o="\\u";
if(G<4096)o+="0"
}
o+=G[db](16)[qd]()
}
n=
ye[n]=o
}
}
G=n
}
s[A]=G
}
g[w]('"');
f=g[ud]("")
}
}
c[w](f==j?"":f)
}
return c[ud]("")
};
am[y].getDataDeps=function(){
return this.dataDeps_
};
var cm=function(){
};
cm[y].render=function(){
};
cm[y].getDataDeps=function(){
};
cm[y].handlesDataDeps=function(){
};
var dm=function(){
};
U(dm,cm);
dm[y].render=function(){
};
dm[y].getDataDeps=function(){
return[]
};
dm[y].handlesDataDeps=function(){
return i
};
dm[y].renderWithContext_=function(){
};
var em=function(a){
this[ad]();
a&&this.addAll(a)
};
Q=em[y];
Q.getCount=function(){
return this.count_
};
Q.getValues=function(){
return ef(this.values_)
};
Q.getKeys=function(){
return ef(this.keys_)
};
Q.containsKey=function(a){
a=Ud(a);
return a in this.keys_
};
Q.isEmpty=function(){
return this.count_==0
};
Ra(Q,function(){
this.keys_={
};
this.values_={
};
this.count_=0
}
);
Ia(Q,function(a){
a=Ud(a);
if(hf(this.keys_,a)){
delete this.values_[a];
this.count_--;
return i
}
return k
}
);
Q.get=function(a,b){
var c=Ud(a);
if(c in this.values_)return this.values_[c];
return b
};
Q.set=function(a,b){
var c=Ud(a);
if(!(c in this.keys_)){
this.keys_[c]=a;
this.count_++
}
this.values_[c]=b
};
Q.addAll=function(a){
var b;
if(a instanceof em){
b=a.getKeys();
a=a.getValues()
}
else{
b=ff(a);
a=ef(a)
}
for(var c=0;
c<b[x];
c++)this.set(b[c],a[c])
};
Q.clone=function(){
return new em(this)
};
var gm=function(a,b){
this.el_=a;
this.doc_=xi(a);
this.outputText_=[];
this.inSpecialOutputContext_=k;
this.specialOutputId_=this.specialOutputTagName_=j;
this.elStack_=[];
this.nodeDepthFromElStack_=0;
this.mode_=b||"SET_CONTENT";
this.createNode_=this.mode_!="SET_CONTENT";
this.replaceNode_=this.mode_=="REPLACE";
if(this.createNode_){
var c=fm[a[bc]]||"DIV";
this.curEl_=this.holder_=q[K](c)
}
else this.curEl_=a;
this.elStack_[w](this.curEl_)
};
U(gm,$l);
var fm={
TR:"TABLE",TD:"TR",OPTION:"SELECT"
}
,hm={
}
,im={
}
,jm={
}
,km={
style:i,script:i
}
,lm={
option:i,tr:i,td:i,tbody:i,thead:i
}
,mm={
br:i,img:i
};
Q=gm[y];
Q.startElement=function(a,b){
var c,e;
if(this.nodeDepthFromElStack_==0&&lm[a]){
for(var f=this.doc_[K](a),g=b[x],h=0;
h<g;
h++){
var n=b[h];
if(n[N]=="id")c=n[D];
else if(n[N]=="g.oncreate"){
e=n[D];
continue
}
f[Pc](n[N],n[D])
}
c&&e&&this.oncreates_[w]({
id:c,script:e
}
);
this.elStack_[w](f);
this.curEl_[v](f);
this.curEl_=f;
this.usedDomInsert_=i
}
else{
this.nodeDepthFromElStack_++;
if(km[a])return this.processSpecialElement_(a,b);
g=hm[a];
if(!g){
g="<"+a;
hm[a]=g
}
f=g;
if(b!=j){
g=b[x];
for(h=0;
h<g;
h++){
n=b[h];
var o=n[N];
n=n[D];
if(o=="id")c=n;
else if(o=="g.oncreate"){
e=n;
continue
}
var s=jm[o];
if(s==j){
s=" "+o+'="';
jm[o]=s
}
f=f+s+se(n)+'"'
}
c&&e&&this.oncreates_[w]({
id:c,script:e
}
)
}
f+=">";
this.outputText_[w](f)
}
};
Q.endElement=function(a){
if(this.nodeDepthFromElStack_>0){
this.nodeDepthFromElStack_--;
if(this.inSpecialOutputContext_)this.inSpecialOutputContext_=k;
else{
if(!mm[a]){
var b=im[a];
if(b==j){
b="</"+a+">";
im[a]=b
}
this.outputText_[w](b)
}
if(this.outputText_[x]>1E3){
a=this.outputText_[ud]("");
this.outputText_=[a]
}
}
}
else{
if(this.curEl_[bd][x]==0)xa(this.curEl_,this.outputText_[ud](""));
this.outputText_=[];
this.elStack_.pop();
this.curEl_=this.elStack_[this.elStack_[x]-1]
}
};
Q.chars=function(a){
if(this.inSpecialOutputContext_)return this.specialOutputChars_(a);
this.outputText_[w](se(a))
};
Q.startOutput=function(){
this.outputText_=[];
this.scripts_=[];
this.oncreates_=[]
};
Q.endOutput=function(){
var a=this.outputText_[ud]("");
if(this.createNode_){
var b=this.holder_;
if(!this.usedDomInsert_)xa(b,a);
if(b[bd][x]==1&&this.replaceNode_)this.el_[O][pb](b[bd][0],this.el_);
else{
if(this.el_[O][bc]=="SELECT")var c=this.el_[O][D];
for(;
a=b[bd][0];
)this.el_[O][Ub](a,this.el_);
this.replaceNode_&&this.el_[O][hc](this.el_);
if(c!=j)za(this.el_[O],c)
}
}
else if(!this.usedDomInsert_)xa(this.el_,a);
pf(this.scripts_,function(e){
eval(e)
}
);
pf(this.oncreates_,function(e){
var f=zi(e.id);
(new Function(e.script))[J](f)
}
)
};
Q.processSpecialElement_=function(a,b){
if(a=="style"){
for(var c,e=0;
e<b[x];
e++)if(b[e][N]=="id")c=b[e][D];
this.specialOutputTagName_="style";
this.specialOutputId_=c+"_ss";
this.inSpecialOutputContext_=i
}
else if(a=="script"){
this.specialOutputTagName_="script";
this.inSpecialOutputContext_=i
}
else d(l("No handler for "+a))
};
Q.specialOutputChars_=function(a){
if(this.specialOutputTagName_=="style")this.addStyle_(this.specialOutputId_,a);
else this.specialOutputTagName_=="script"&&this.scripts_[w](a)
};
Q.createStyleSheet_=function(a){
var b=j,c=Z(a);
if(c==j){
c=this.doc_[K]("style");
c[Pc]("type","text/css");
c[Pc]("id",a);
this.doc_[dc][v](c)
}
for(c=0;
c<this.doc_.styleSheets[x];
c++){
var e=this.doc_.styleSheets[c],f=e.owningElement;
if(f==j)f=e.ownerNode;
if(f.id==a)b=e
}
return b
};
Q.addStyle_=function(a,b){
if(!Z(a)){
var c=this.createStyleSheet_(a),e=b[Fb]("
        }
        ");
if(c.insertRule)for(var f=0;
f<e[x];
f++)e[f]!=""&&c.insertRule(e[f]+"
    }
    ",0);
else if(c.cssText!=j)for(f=0;
f<e[x];
f++)if(e[f]!=""){
var g=e[f][Fb]("{
        "),h=g[0];
g=g[1];
h=h[Fb](",");
for(var n=0;
n<h[x];
n++)h[n]!=""&&c.addRule(h[n],g)
}
}
};
var nm=function(){
this.dirty_=new em;
this.timer_=j;
this.redrawCallback_=T(this.redraw_,this)
};
Q=nm[y];
Q.markDirty=function(a,b,c){
if(!Qd(c))d(l("not a function: "+c));
if(!a.getDepth)d(l("Nodes for markDirty must support getDepth"));
b=b||[];
b=b[ud](",");
var e=this.dirty_.get(a);
if(!e){
e={
};
this.dirty_.set(a,e)
}
e[b]||(e[b]=[]);
a=e[b];
c=c;
Qe(a,c)||a[w](c);
this.schedule_()
};
Q.markClean=function(a,b){
b=b||[];
var c=this.dirty_.get(a);
if(c)if(b[x]==0)this.dirty_[wc](a);
else{
var e=m(b);
delete c[e];
c[x]==0&&this.dirty_[wc](a)
}
};
Q.schedule_=function(){
if(!this.timer_)this.timer_=S[yb](this.redrawCallback_,50)
};
Q.redraw_=function(){
delete this.timer_;
var a=this.dirty_.getKeys();
a[Mc](function(e,f){
return e.getDepth()-f.getDepth()
}
);
for(var b=0;
b<a[x];
b++){
var c=a[b];
this.redrawOneDirty_(c);
this.dirty_[wc](c)
}
};
Q.redrawOneDirty_=function(a){
for(;
;
){
var b=this.dirty_.get(a),c=this.getFirst_(b);
if(c==j)break;
for(var e=c==""?[]:c[Fb](","),f=b[c],g=0;
g<f[x];
g++){
var h=f[g];
h[J](a,j,"",e)
}
delete b[c]
}
};
Q.getFirst_=function(a){
if(a!=j)for(var b in a)return b;
return j
};
var om=function(a,b,c,e,f){
this.nodeName_=a[bc];
this.owner_=c;
this.depth_=e;
this.templateNodeParams_=f;
this.readAttributes_(a);
this.setDataContext_(b);
this.createChildNodes_(a)
}
,pm=Of("goog.focus.TemplateNode"),qm=j,rm=0,sm=function(){
qm||(qm=new nm);
return qm
};
Q=om[y];
Q.outputTopNode_=i;
Q.getDepth=function(){
return this.depth_
};
Q.dispose=function(){
};
Q.readAttributes_=function(a){
this.atts_={
};
a=a[hd];
for(var b=0,c;
c=a[b];
++b){
var e=c[bc];
c=c[yd];
if(c!=j)if(e=="if")this.ifExpr_=ll(this.expandTemplateNodeParams_(c));
else if(e=="context")this.contextExpr_=W(c);
else if(e=="repeat")this.repeatExpr_=W(this.expandTemplateNodeParams_(c));
else if(e=="id"){
this.id_=c;
this.idExpr_=bm(this.id_)
}
else{
var f=be(e,"on")||e=="g.oncreate";
this.atts_[e]=bm(c,f?1:0)
}
}
};
Q.getTemplateNodeParameterValue=function(a){
var b=j;
if(this.templateNodeParams_)b=this.templateNodeParams_.getChildNodeValue(a);
if(!b&&this.owner_)b=this.owner_.getTemplateNodeParameterValue(a);
return b
};
Q.expandTemplateNodeParams_=function(a){
var b=/\{
\{
\$View\/@[a-zA-Z]*?\
}
\
}
/g;
b=a[nc](b);
if(!b)return a;
for(var c=0;
c<b[x];
c++){
var e=b[c],f=e[Sc](8,e[x]-2);
if(f=this.getTemplateNodeParameterValue(f))a=a[B](e,f)
}
return a
};
Q.setDataContext_=function(a){
this.outputDataContext_=this.rootDataContext_=a;
if(this.contextExpr_)this.outputDataContext_=this.getRelativeExpr_(this.contextExpr_,i);
if(this.repeatExpr_)this.outputDataContext_=this.getRelativeExpr_(this.repeatExpr_,i)
};
Q.getRelativePath_=function(a,b){
var c=a.getSource(),e=b?this.rootDataContext_:this.outputDataContext_;
if(c[E]("$")!=0&&e)c=e.getSource()+"/"+c;
return c
};
Q.getRelativeExpr_=function(a,b){
return W(this.getRelativePath_(a,b))
};
Q.init=function(){
if(!this.initialized_){
this.addDataListeners_();
if(!this.id_){
this.id_="Node"+rm++;
this.idExpr_=bm(this.id_)
}
this.initialized_=i
}
};
Q.addDataListeners_=function(){
if(this.ifExpr_){
var a=this.createDirtyCallback_(this.checkVisibility_);
this.listenTo_(this.ifExpr_,a,i)
}
if(this.repeatExpr_){
a=this.createDirtyCallback_(this.updateRepeated_);
this.listenTo_(this.outputDataContext_.getParent(),a,i)
}
a=this.createDirtyCallback_(this.updateElement_);
for(var b=0;
b<this.childNodes_[x];
b++){
var c=this.childNodes_[b];
c.handlesDataDeps()||this.listenTo_(c,a,k)
}
for(var e in this.atts_)this.listenTo_(this.atts_[e],a,k)
};
Q.createDirtyCallback_=function(a){
var b=this;
return function(c,e,f){
sm().markDirty(b,f,a,c)
}
};
Q.listenTo_=function(a,b,c){
var e=V();
if(a.getDataDeps){
a=a.getDataDeps();
for(var f=0;
f<a[x];
f++){
var g=this.getRelativePath_(a[f],c);
e.addIndexedListener(b,g)
}
}
else{
g=a.src_;
e.addIndexedListener(b,g)
}
};
Q.createChildNodes_=function(a){
if(!this.childNodes_){
var b=this.nodeName_=="script"?1:0;
this.childNodes_=[];
a=a[bd];
for(var c=0,e;
e=a[c];
++c)if(!(e[zb]==3&&/^[\n\r\t ]*$/[lb](e[yd]))){
e=tm().createView(e,this.outputDataContext_,this.owner_,this.depth_+1,b);
this.childNodes_[w](e)
}
}
};
Q.isVisible_=function(){
return this.ifExpr_?this.ifExpr_.getValue(this):i
};
Q.render=function(a,b){
if(b&&b.getChildNode)b=W(b.getDataPath());
if(b){
this.setDataContext(b);
this.createChildNodes_()
}
this.renderImpl_(a)
};
Q.setIndexes_=function(a){
this.indexes_=a||[];
this.ds_=this.getDataSource_(this.indexes_)
};
Q.getAttributes_=function(a,b){
var c=[],e;
for(e in this.atts_)if(!a||e!="style"){
var f=this.atts_[e].getValue(this)||"";
c[w]({
name:e,value:f
}
)
}
e=b||this.getElementId_();
c[w]({
name:"id",value:e
}
);
if(a){
e=this.atts_[H];
e=(e?e.getValue(this)+";
        ":"")+"display: none";
c[w]({
name:"style",value:e
}
)
}
return c
};
Q.startElement_=function(a,b,c){
this.outputTopNode_&&a.startElement(b,c)
};
Q.endElement_=function(a,b){
this.outputTopNode_&&a.endElement(b)
};
Q.renderImpl_=function(a,b,c){
sm().markClean(this,this.indexes_);
var e=this.nodeName_,f=this.isVisible_();
if(this.repeatExpr_&&!b){
this.renderRepeated_(a,c);
this.rendered_=i
}
else if(f){
b=this.getAttributes_();
this.startElement_(a,e,b);
this.renderChildren_(a);
this.endElement_(a,e);
this.rendered_=i
}
else if(e!="option"){
b=this.getAttributes_(i);
if(this.outputTopNode_){
a.startElement(e,b);
a.endElement(e)
}
}
};
Q.renderRepeated_=function(a,b){
for(var c=W(this.getExpr_(this.indexes_)).getNodes(),e=this.nodeName_,f=0;
f<c.getCount();
f++){
var g=c.getByIndex(f);
this.indexes_[w](g.getDataName());
this.ds_=this.getDataSource_(this.indexes_);
if(this.isVisible_()){
g=this.getAttributes_();
this.startElement_(a,e,g);
this.renderChildren_(a);
this.endElement_(a,e);
this.addIndexedElement_()
}
this.indexes_.pop()
}
if(!b&&e!="option"){
this.repeatEl_=this.getElementId_()+"-R";
c=this.getAttributes_(i,this.repeatEl_);
this.startElement_(a,
e,c);
this.endElement_(a,e)
}
};
Q.addIndexedElement_=function(){
if(!this.els_)this.els_={
};
for(var a=this.els_,b=0;
b<this.indexes_[x]-1;
b++){
a[this.indexes_[b]]||(a[this.indexes_[b]]={
}
);
a=a[this.indexes_[b]]
}
a[m(this.indexes_[this.indexes_[x]-1])]=this.getElementId_()
};
Q.possiblyRenderElement_=function(a){
var b=this.isVisible_(),c=a[H][ld]!="none";
if(b!=c){
b&&this.renderElement_(a);
Wa(a[H],b?"":"none");
if(!b)for(sm().markClean(this,this.indexes_);
a[lc];
)a[hc](a[lc])
}
};
Q.renderElement_=function(a){
a=new gm(a,"REPLACE");
this.log_("render in renderElement");
a.startOutput();
this.renderImpl_(a,i);
a.endOutput()
};
Q.renderChildren_=function(a){
this.createChildNodes_();
for(var b=0;
b<this.childNodes_[x];
b++){
var c=this.childNodes_[b];
if(c.renderWithContext_)c.renderWithContext_(a,this);
else{
c.init();
c.setIndexes_(this.indexes_);
c.render(a)
}
}
};
Q.getElementId_=function(){
var a=this.idExpr_.getValue(this);
if(this.indexes_)for(var b=0;
b<this.indexes_[x];
b++)a+="-"+this.indexes_[b];
return a
};
Q.getElement_=function(){
return Z(this.getElementId_())
};
Q.getDataSource_=function(a){
a=this.getExpr_(a);
return a=W(a).getNode()
};
Q.getExpr_=function(a){
var b=this.outputDataContext_?this.outputDataContext_.src_:"";
if(a)for(var c=0;
c<a[x];
c++)b=b[B](/\*/,a[c]);
return b
};
Q.log_=function(a){
if(pm.isLoggable(If)){
for(var b=[a,"View=",this.owner_.id_," Node=",this.id_],c=1;
c<arguments[x];
c++)b[w](arguments[c]);
pm.log(If,b[ud](", "))
}
};
Q.updateElement_=function(a,b,c){
this.setIndexes_(c);
(a=this.getElement_())&&this.renderElement_(a)
};
Q.updateRepeated_=function(a,b,c){
if(a=Z(this.repeatEl_)){
c=c||[];
a=this.els_;
for(b=0;
b<c[x];
b++)a=this.els_[m(c[b])];
for(var e in a){
b=a[e];
(b=Z(b))&&b[O][hc](b)
}
for(e in a)delete a[e];
this.setIndexes_(c);
c=new gm(Z(this.repeatEl_),"INSERT_BEFORE");
this.log_("render in updateRepeated");
c.startOutput();
this.renderImpl_(c,j,i);
c.endOutput()
}
};
Q.checkVisibility_=function(a,b,c){
this.setIndexes_(c);
(a=this.getElement_())&&this.possiblyRenderElement_(a)
};
Q.handlesDataDeps=function(){
return i
};
Q.getChildNode=function(a){
if(a=="$Context"){
a=this.getExpr_(this.indexes_);
var b=W(a);
if(b.getNode())var c=b.getNode().getDataName();
else if(this.indexes_)c=this.indexes_[this.indexes_[x]-1];
if(b&&b.getParent()){
var e=b.getParent().getNode(),f=e.getChildNodes().getCount()-1;
e=e.getChildNodes()[E](c)
}
if(a!="")a+="/";
b=this.indexes_[x]>0?"-"+this.indexes_[ud]("-"):"";
var g=this.owner_?this.owner_.viewId_:"";
return c=new wk({
"@dataName":c,"@cid":b,"@vid":g,"@dataPath":a,"@last":f,"@index":e
}
,"Context")
}
else return a==
"$View"?this.owner_.templateNodeParams_:a[E]("$")==0?V().getChildNode(a):this.ds_?this.ds_.getChildNode(a):j
};
Q.getChildNodeValue=function(a){
return a=="$Context"?new wk({
}
,"Context"):a[E]("$")==0?V().getChildNodeValue(a):this.ds_?this.ds_.getChildNodeValue(a):""
};
Q.getChildNodes=function(a){
return this.ds_?this.ds_.getChildNodes(a):new Rf
};
Q.getDataRoot=function(){
return this
};
var um=function(a,b){
this.text_=a;
this.textTemplate_=bm(a,b);
this.dataDeps_=this.textTemplate_.getDataDeps()
};
um[y].renderWithContext_=function(a,b){
a.chars(fe(this.textTemplate_.getValue(b)))
};
um[y].getDataDeps=function(){
return this.dataDeps_
};
um[y].handlesDataDeps=function(){
return k
};
var wm=function(a,b,c,e){
om[J](this,a,b,this,e,c);
this.viewId_=vm++;
this.outputTopNode_=k
};
U(wm,om);
var vm=0,xm=function(a,b,c,e){
om[J](this,a,b,c,e)
};
U(xm,om);
xm[y].renderImpl_=function(a){
var b="span";
this.startElement_(a,b,this.getAttributes_());
var c=this.atts_[sb].getValue(this);
if(c){
c=c[B]("\n\r","\n");
c=c[Fb](/[\n\r]/);
for(var e=0;
e<c[x];
e++){
var f=c[e];
if(e>0){
a.startElement("br",[]);
a.endElement("br")
}
a.chars(f)
}
}
this.endElement_(a,b)
};
var zm=function(){
var a={
};
pf(ym,function(b){
a[b]=i
}
);
this.htmlNameMap_=a;
this.views_={
};
this.viewTemplates_={
};
this.customViewCreators_={
};
this.numLoadsOutstanding_=0;
this.waitingOnLoadListeners_=[]
}
,Am,tm=function(){
if(Am==j)Am=new zm;
return Am
};
Q=zm[y];
Q.createView=function(a,b,c,e,f){
e=e||0;
var g=a[bc];
if(g=="#text")return new um(a[yd],f);
else if(g=="#comment")return new dm;
else if(g=="MultilineText")return new xm(a,b,c,e);
else if(this.htmlNameMap_[g])return new om(a,b,c,e);
else if(g=="View")return new wm(a,b,j,e);
else if(this.viewTemplates_[g])return new wm(this.viewTemplates_[g],b,this.createParamDs_(a),e);
else if(this.customViewCreators_[g])return this.customViewCreators_[g](a,b,c);
else d(l("No view exists matching name: "+g))
};
Q.createParamDs_=function(a){
for(var b={
}
,c=a[hd][x],e=0;
e<c;
++e){
var f=a[hd][e];
b["@"+f[bc]]=f[yd]
}
return hi(b,"$View")
};
Q.addXmlView=function(a){
if(a[Dd])a=a[Dd];
this.numLoadsOutstanding_++;
if(a[Ec])this.addViews_(a);
else{
var b=new Nh;
Y(b,"success",this.documentReceived_,k,this);
b[pc](a)
}
};
Q.documentReceived_=function(a){
var b=a[I].getResponseXml()[Dd],c=this;
S[yb](function(){
c.addViews_(b)
}
,0)
};
Q.addViews_=function(a){
var b=a[bd];
a=[];
for(var c=0,e;
e=b[c];
++c)e[zb]==1&&a[w](e);
for(c=0;
c<a[x];
c++){
b=a[c][Ac]("id");
this.addView(b,a[c])
}
this.numLoadsOutstanding_--;
Sk()[Oc]("load");
this.callWaitingOnLoadListeners_()
};
Q.addView=function(a,b){
this.viewTemplates_[a]=b
};
Q.callWaitingOnLoadListeners_=function(){
if(this.numLoadsOutstanding_==0){
var a=this.waitingOnLoadListeners_;
this.waitingOnLoadListeners_=[];
for(var b=0;
b<a[x];
b++)a[b]()
}
};
var ym=["p","div","b","i","br","ul","li","a","hr","span","img","table","tr","select","option","td","th","tbody","#text","h1","h2","h3","dl","dt","input","iframe","form","textarea","col","#comment","strike","button","script","style","thead","link","em","ol","label"];
zm[y].renderView=function(a,b,c,e){
if(e){
var f=V(),g;
for(g in e)f.addDataSource(new wk(e[g],g))
}
c=c?W(c.getDataPath()):j;
a=this.createView(this.viewTemplates_[a],c,j);
b=new gm(b);
b.startOutput();
a.render(b);
b.endOutput()
};
var Bm="/ui/",Cm=function(a){
Bm=a
};
S.HtmlUtil_setServerBase=Cm;
var Dm=function(a,b){
var c=b=="TWO"?502:750;
c=new vj(0,0,c,500);
c="toolbar=no,location=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+c[z]+",height="+c[P]+",top="+c.top+",left="+c[ec];
var e,f=b;
e=new Sh(Bm+"ContactManager");
f=f||"THREE";
e.setParameterValue("style",f);
e.setParameterValue("js","RAW");
e.setParameterValue("pop","TRUE");
e=e;
e=e[db]();
p[kb](e,"_manager",c)
};
ul("goog.focus.ContactManagerLauncher.popManager",Dm);
var Em=function(a,b,c,e,f,g,h,n,o){
this.profileMode_=a;
this.userName_=b;
this.pictureUrl_=c;
this.callback_=e;
this.theme_=f||"";
this.window_=g;
this.noPhotoUrl_=h;
this.locale_=o;
this.serverPath_=n||Wl().getServerBase();
this.installPhotoPicker_()
};
Q=Em[y];
Q.launch_=function(){
if(!W("$UserData").getNode()||!W("$AuthToken").getNode()){
var a=new Nh;
Y(a,"complete",this.handleAuthStatusResponse_,k,this);
a[pc](this.serverPath_+"/gastatus?out=js","GET")
}
else this.launchImpl_()
};
Q.handleAuthStatusResponse_=function(a){
a=a[I];
if(a.isSuccess()){
a=Fm(a.getResponseText());
if(a.Body){
var b=a.Body.UserData;
b=new ei(b,"UserData");
V().addDataSource(b);
a=a.Body.AuthToken;
a=new ei(a,"AuthToken");
V().addDataSource(a)
}
}
this.launchImpl_()
};
Q.launchImpl_=function(){
Wl().displayIframe("photopicker.PhotoPicker",this.getParams_(),T(this.handleWidgetCallback,this),this.window_)
};
Q.sendToWidget_=function(a){
Wl().sendToWidget("photopicker.PhotoPicker",a,this.window_)
};
Q.getParams_=function(){
var a={
};
if(this.profileMode_)a.profileMode="1";
a.dn=this.userName_;
a.eUrl=this.pictureUrl_;
if(this.theme_)a.theme=this.theme_;
if(this.noPhotoUrl_)a.dpUrl=this.noPhotoUrl_;
if(this.locale_)a.hl=this.locale_;
var b=W("$UserData/IsPicasaUser").getValue(),c=W("$UserData/Email").getValue();
b=b&&c&&(ce(c,"gmail.com")||ce(c,"googlemail.com"));
a.userId=b?c[Sc](0,c[E]("@")):j;
a.urlEnabled=1;
a.extraUploadParams="out=hjs";
a.suppressHide="1";
return a
};
var Fm=function(a){
var b=a[E]("&&&START&&&")+11,c=a[yc]("&&&END&&&");
return wh(a[Sc](b,c))
};
Q=Em[y];
Q.sendServletRequest_=function(a,b){
var c=new Nh,e=this.createPostContent_(a);
Y(c,"complete",T(this.handleServletRequest_,this,b),k,this);
c[pc](this.serverPath_+"/update/photos","POST",e)
};
Q.handleServletRequest_=function(a,b){
var c=j,e=b[I];
if(e.isSuccess())c=Fm(e.getResponseText());
a[J](this,c)
};
Q.createPostContent_=function(a){
var b=new Th;
b.add("out","js");
b.add("tok",this.getAuthToken_());
this.locale_&&b.add("hl",this.locale_);
for(var c in a)b.add(c,a[c]);
return b[db]()
};
Q.getAuthToken_=function(){
var a=W("$AuthToken/Value").getNode();
return a?a.get():j
};
Q.resolvePhotoUrl_=function(a){
return this.serverPath_+a
};
Q.closePhotoPicker_=function(){
Wl().hideIframeDialog("photopicker.PhotoPicker");
Wl().sendToWidget("photopicker.PhotoPicker",{
type:"CLOSE_NO_REMOVE"
}
);
Wl().eraseIframeDialog("photopicker.PhotoPicker");
Sk()[Oc]("ENABLE_WINDOW");
Gm=k
};
Q.installPhotoPicker_=function(){
Hm()
};
var Im=function(a,b,c,e,f,g,h,n){
this.contactId_=a;
Em[J](this,k,b,c,e,"",f,g,h,n)
};
U(Im,Em);
Q=Im[y];
Q.handleWidgetCallback=function(a){
var b=this.contactId_,c=a[Zc];
if(c=="PHOTO_PICKED")if(a.evergreen)this.chooseEvergreen(b);
else a.noPhoto?this.deletePhoto(b):this.savePhoto(b,a.imageUrl,a.cropString);
else c=="SUGGEST_DONE"&&a.suggestMessage?this.sendPhotoSuggestion(b,a.suggestMessage):this.closePhotoPicker_()
};
Q.savePhoto=function(a,b,c){
this.sendServletRequest_({
cid:a,photo:b,crop:c,create:"true",action:"SET"
}
,this.photoSaved_)
};
Q.chooseEvergreen=function(a){
this.sendServletRequest_({
cid:a,create:"true",action:"SET_EVERGREEN"
}
,this.photoSaved_)
};
Q.deletePhoto=function(a){
this.sendServletRequest_({
cid:a,create:"true",action:"DELETE"
}
,this.photoDeleted_)
};
Q.sendPhotoSuggestion=function(a,b){
this.sendServletRequest_({
cid:a,msg:b,action:"SUGGEST"
}
,this.photoSuggestionSent_)
};
Q.photoSaved_=function(a){
var b={
action:"SET"
};
var c=(a=a&&a.Success&&a.Body||j)&&a.Contact;
if(c){
b.success=i;
this.setEventFieldsFromContact_(b,c)
}
else b.success=k;
this.callback_(b);
if(c&&c.Photo&&a.CanSuggest){
b={
type:"SHOW_SUGGEST",imageUrl:this.resolvePhotoUrl_(c.Photo)
};
this.sendToWidget_(b)
}
else this.closePhotoPicker_()
};
Q.photoDeleted_=function(a){
var b={
action:"DELETE"
};
if(a=(a=a&&a.Success&&a.Body||j)&&a.Contact){
b.success=i;
this.setEventFieldsFromContact_(b,a)
}
else b.success=k;
this.callback_(b);
this.closePhotoPicker_()
};
Q.photoSuggestionSent_=function(a){
var b={
action:"SUGGEST"
};
b.success=!!(a&&a.Success);
this.callback_(b);
this.closePhotoPicker_()
};
Q.setEventFieldsFromContact_=function(a,b){
a.contact=b;
var c=b.Photo,e=b.EvergreenPhoto;
a.localPhotoUrl=c?c==e?j:c:"";
a.evergreenPhotoUrl=e||j
};
var Jm=function(a,b,c,e,f,g,h,n){
if(!Gm){
a=new Im(a,b,c,e,f,g,h,n);
a.launch_()
}
};
p.launchContactPhotoPicker=Jm;
var Km=function(a,b){
this.el_=a;
this.widgetParams_=b;
this.pictureExists_=b.exists=="true";
this.eventKeys_=[];
this.attachMouseListeners_(a);
this.pictureExists_||this.createTextDiv_(jk("ADD_PICTURE"),k,i)
};
Q=Km[y];
Q.dispose=function(){
for(var a=0;
a<this.eventKeys_[x];
a++)nh(this.eventKeys_[a]);
this.textDiv_&&this.textDiv_[O]&&this.textDiv_[O][hc](this.textDiv_);
this.borderDiv_&&this.textDiv_.borderDiv_&&this.borderDiv_[O][hc](this.textDiv_)
};
Q.attachMouseListeners_=function(a){
this.eventKeys_[w](Y(a,"mouseover",this.onMouseOver_,k,this));
this.eventKeys_[w](Y(a,"mouseout",this.onMouseOut_,k,this));
this.eventKeys_[w](Y(a,"click",this.overlayClick_,k,this))
};
Q.div_=j;
Q.hideTimer_=j;
Q.onMouseOver_=function(){
if(this.borderDiv_)this.cancelHideTimer_();
else{
this.borderDiv_=this.createBorderDiv_();
this.pictureExists_&&this.createTextDiv_(jk("CHANGE_PICTURE"),i)
}
};
Q.createBorderDiv_=function(){
var a=Mj(this.el_);
a.width-=Al(this.el_);
a.height-=Bl(this.el_);
if(X){
a.width+=4;
a.height+=4
}
a.width+=2;
a.height+=2;
var b=Ki("div");
this.attachMouseListeners_(b);
ra(b[H],"absolute");
b[H].zIndex=20;
Lj(b,a);
Sa(b[H],"2px solid blue");
a=Hj(this.el_);
a.x-=3;
a.y-=3;
this.el_[O][Ub](b,this.el_);
Kj(b,a);
return b
};
Q.createTextDiv_=function(a,b,c){
if(this.el_[O]){
var e=Ki("div");
this.attachMouseListeners_(e);
b=b?"background-color: white;
        ":"";
xa(e,'<div style="text-align: center;
        '+b+'font-family: Arial;
        font-size: 12px;
padding: 2px"><a href="javascript:void(0)" class="cmgr-link">'+a+"</a></div>");
ra(e[H],"relative");
e[H].zIndex=20;
a=this.el_;
a[O]&&a[O][Ub](e,a[md]);
a=(this.el_[td]+e[td])/2;
e[H].top="-"+a+"px";
this.textDiv_=e;
this.center_=c
}
};
Q.onMouseOut_=function(a){
if(this.borderDiv_){
a=a[nb];
if(!a||a!=this.el_&&!Ui(this.borderDiv_,a))this.hideOverlay_(i)
}
};
Q.overlayClick_=function(){
this.hideOverlay_(k);
var a=W("$Contacts/"+this.widgetParams_.contactid).getNode(),b=V().getChildNodeValue("$Locale")[db]();
Jm(a.getId(),a.getNameForDisplay(),a.getPictureUrl(i),T(this.handlePickerCallback_,this),ba,ba,Lm().getFfeServerPath(),b)
};
Q.hideOverlay_=function(a){
this.cancelHideTimer_();
if(a){
a=T(this.hideOverlay_,this,k);
this.hideTimer_=S[yb](a,20)
}
else if(this.el_&&this.borderDiv_){
this.borderDiv_[O][hc](this.borderDiv_);
this.borderDiv_=j;
if(this.pictureExists_){
this.textDiv_[O][hc](this.textDiv_);
this.textDiv_=j
}
}
};
Q.cancelHideTimer_=function(){
if(this.hideTimer_){
S[qb](this.hideTimer_);
this.hideTimer_=j
}
};
Q.handlePickerCallback_=function(a){
var b=a[Yc],c=a.success;
a=a.contact;
if(b=="SET")Lm().onPhotoSaved(c,a);
else if(b=="DELETE")Lm().onPhotoDeleted(c,a);
else b=="SUGGEST"&&Lm().onPhotoSuggested(c)
};
var Mm=function(){
}
,Nm,Om={
}
,Gm=k;
Mm[y].getId=function(){
return"photopicker.PhotoPicker"
};
var Hm=function(){
if(!Nm){
var a=new Mm;
Wl().registerInline(a);
Nm=i
}
};
Mm[y].attach=function(a,b){
for(var c in Om){
var e=Om[c];
if(!e.el_||!Ui(q,e.el_)){
e.dispose();
delete Om[c]
}
}
if(a&&!Om[a.id]){
c=new Km(a,b);
Om[a.id]=c
}
};
Mm[y].displayIframe=function(a,b,c){
if(!Gm){
Gm=i;
var e=new mi(545,332);
Wl().createIframeDialog(this.getId(),e,a,b,c);
Sk()[Oc]("DISABLE_WINDOW")
}
};
var Pm,Qm,Rm,Sm=function(a,b){
var c=307,e;
if(X)c+=5;
if(a){
e=Hj(a);
var f=Mj(a);
e.y+=f[P]
}
else e=new ki(0,0);
c=f[z]>c?f[z]:c;
f=554;
var g=313,h=600;
if(b){
e.x+=b[jc]-b[Bd];
e.y+=b[kc]-b[Cd]
}
if(e.x+g>ka[z])e.x=ka[z]-g;
if(e.y+h>ka[P])e.y=ka[P]-h;
return e=new vj(e.x,e.y,c,f)
}
,Um=function(a,b){
var c=new Sh(Bm[B](/ui\/?$/,"")),e=c,f=b,g,h;
if(a){
h=Z(a);
g=h[Ac]("id")
}
else g=j;
c=!ng&&h?Ii(xi(h))||p:p;
h=Sm(h,f);
f="toolbar=no,location=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+h[z]+",height="+h[P]+
",top="+h.top+",left="+h[ec];
e=Tm(e,g,void 0);
e.setParameterValue("width",h[z]);
e.setParameterValue("height",h[P]);
if(!Pm||Pm.closed)Pm=c[kb](e[db](),"_picker",f);
Pm[zc]()
}
,Tm=function(a,b,c){
a=a.resolve(new Sh("ui/ContactPicker"));
b&&a.setParameterValue("inputId",b);
if(c){
c.serviceName&&a.setParameterValue("service",c.serviceName);
c.hl&&a.setParameterValue("hl",c.hl)
}
return a
}
,Wm=function(a,b,c){
Qm&&Vm();
var e=new Sh(Bm[B](/ui\/?$/,""));
b=Z(a);
b=Sm(b,j);
a=Tm(e,a,c);
p.iframeDone=Vm;
a.setParameterValue("done",
"iframeDone");
e="PICKER_IFRAME_DIV_ID";
var f="PICKER_IFRAME_ID";
c=Z(e);
if(c==j){
c=Ki("div",{
id:e,style:"position: absolute;
        background-color;
#FFF",zIndex:10
}
);
q[dc][v](c);
xa(c,'<iframe id="'+f+'" style="display: none;
        background-color;
#FFF;
border: 0"></iframe>')
}
e=Z(f);
Wa(e[H],"block");
Kj(c,b[ec],b.top);
Lj(e,b[z],b[P]);
e.src=a;
Rm=c;
Qm=e
}
,Vm=function(){
Ri(Rm);
Qm=Rm=j
};
Hd("goog.focus.PickerLauncher.popPicker",Um,void 0);
Hd("goog.focus.PickerLauncher.popIframe",Wm,void 0);
var Xm,Ym,Zm,$m=function(a,b){
var c=307,e;
if(a){
e=Hj(a);
var f=Mj(a);
e.y+=f[P]
}
else e=new ki(0,0);
c=f[z]>c?f[z]:c;
f=554;
var g=313,h=600;
if(b){
e.x+=b[jc]-b[Bd];
e.y+=b[kc]-b[Cd]
}
if(e.x+g>ka[z])e.x=ka[z]-g;
if(e.y+h>ka[P])e.y=ka[P]-h;
return new vj(e.x,e.y,c,f)
}
,bn=function(a,b,c){
var e=new Sh(Bm[B](/ui\/?$/,""));
e=e;
b=b;
c=c;
var f,g;
if(a){
g=Z(a);
f=g[Ac]("id")
}
else f=j;
a=!ng&&g?Ii(xi(g))||p:p;
g=$m(g,b);
g="toolbar=no,location=no,menubar=no,scrollbars=no,resizable=yes,status=no,width="+g[z]+",height="+g[P]+
",top="+g.top+",left="+g[ec];
e=an(e,f,c);
if(!Xm||Xm.closed)Xm=a[kb](e[db](),"_chooser",g);
Xm[zc]()
}
,an=function(a,b,c){
a=a.resolve(new Sh("widgets/ContactChooser"));
b&&a.setParameterValue("inputId",b);
if(c){
c.serviceName&&a.setParameterValue("service",c.serviceName);
c.hl&&a.setParameterValue("hl",c.hl);
c.tempTitle&&a.setParameterValue("tempTitle",c.tempTitle)
}
return a
}
,dn=function(a,b,c){
Ym&&cn();
var e=new Sh(Bm[B](/ui\/?$/,""));
b=Z(a);
b=$m(b,j);
a=an(e,a,c);
p.iframeDone=cn;
a.setParameterValue("done",
"iframeDone");
c=Z("chooser-iframe-div");
if(c==j){
c=Ki("div",{
id:"chooser-iframe-div",style:"position: absolute;
        background-color;
#FFF",zIndex:10
}
);
q[dc][v](c);
xa(c,'<iframe id="chooser-iframe" style="display:none;
        background-color;
#FFF;
border: 0"></iframe>')
}
e=Z("chooser-iframe");
Wa(e[H],"block");
Kj(c,b[ec],b.top);
Lj(e,b[z],b[P]);
e.src=a;
Zm=c;
Ym=e
}
,cn=function(){
Ri(Zm);
Ym=Zm=j
};
Hd("goog.focus.ChooserLauncher.popChooser",bn,void 0);
Hd("goog.focus.ChooserLauncher.popIframe",dn,void 0);
var en=function(a,b,c,e,f,g,h,n,o){
Em[J](this,i,a,b,c,f,g,h,n,o);
this.setPublic_=!!e
};
U(en,Em);
en[y].handleWidgetCallback=function(a){
a[Zc]=="PHOTO_PICKED"?this.sendUpdateRequest_(a):this.closePhotoPicker_()
};
en[y].sendUpdateRequest_=function(a){
if(!a.evergreen){
var b={
cid:"p"
};
if(a.noPhoto)Na(b,"DELETE");
else{
Na(b,"SET");
b.crop=a.cropString;
b.photo=a.imageUrl
}
if(this.setPublic_)b.p="true";
this.sendServletRequest_(b,T(this.handleUpdateResponse_,this,b[Yc]))
}
};
en[y].handleUpdateResponse_=function(a,b){
this.closePhotoPicker_();
var c={
action:a
};
if(b&&b.Success){
c.success=i;
if(b.Body){
c.newUrl=b.Body.NewUrl;
c.newUrlF=b.Body.NewUrlF
}
}
else c.success=k;
this.callback_(c)
};
var fn=function(a,b,c,e,f,g,h,n,o){
if(!Gm){
a=new en(a,b,c,e,f,g,h,n,o);
a.launch_()
}
};
p.launchProfilePhotoPicker=fn;
var gn=function(a,b,c){
wk[J](this,j,b,j);
this.uri_=a?new Sh(a):j;
this.callbackParamName_=c||"callback"
};
U(gn,wk);
gn[y].loadState_="NOT_LOADED";
gn.dataSources={
};
wa(gn[y],function(){
if(this.uri_){
gn.dataSources[this.dataName_]=this;
Uf.info("Sending JS request for DataSource "+this.getDataName()+" to "+this.uri_);
this.loadState_="LOADING";
var a=new Sh(this.uri_);
a.setParameterValue(this.callbackParamName_,"JsonReceive."+this.dataName_);
S.JsonReceive[this.dataName_]=T(this.receiveData,this);
a=Ki("script",{
src:a
}
);
Bi("head")[0][v](a)
}
else{
this.root_={
};
this.loadState_="NOT_LOADED"
}
}
);
gn[y].receiveData=function(a){
this.setRoot(a);
this.loadState_="LOADED";
V().fireDataChange(this.getDataName())
};
S.JsonReceive={
};
var hn=function(a,b,c){
this.parent_=b;
this.dataName_=c||(a?a[bc]:"");
this.setNode_(a)
};
Q=hn[y];
Q.setNode_=function(a){
this.node_=a;
if(a!=j)switch(a[zb]){
case 2:case 3:this.value_=a[yd];
break;
case 1:if(a[bd][x]==1&&a[Ec][zb]==3)this.value_=a[Ec][yd]
}
};
Q.createChildNodes_=function(){
if(!this.childNodeList_){
var a=new Sf;
if(this.node_!=j)for(var b=this.node_[bd],c=0,e;
e=b[c];
c++)if(e[zb]!=3||!/^[\r\n\t ]*$/[lb](e[yd])){
e=new hn(e,this,e[bc]);
a.add(e)
}
this.childNodeList_=a
}
};
Q.createAttributes_=function(){
if(!this.attributes_){
var a=new Sf;
if(this.node_!=j&&this.node_[hd]!=j)for(var b=this.node_[hd],c=0,e;
e=b[c];
c++){
e=new hn(e,this,e[bc]);
a.add(e)
}
this.attributes_=a
}
};
Q.get=function(){
this.createChildNodes_();
return this.value_
};
Q.set=function(){
d(l("Can't set on XmlDataSource yet"))
};
Q.getChildNodes=function(a){
if(a&&a=="@*"){
this.createAttributes_();
return this.attributes_
}
else if(a==j||a=="*"){
this.createChildNodes_();
return this.childNodeList_
}
else d(l("Unsupported selector"))
};
Q.getChildNode=function(a){
if(be(a,"@"))return(a=this.node_.getAttributeNode(a[Sc](1)))?new hn(a,this):j;
else return this.getChildNodes().get(a)
};
Q.getChildNodeValue=function(a){
if(be(a,"@"))return(a=this.node_.getAttributeNode(a[Sc](1)))?a[yd]:j;
else return(a=this.getChildNode(a))?a.get():j
};
Q.getDataName=function(){
return this.dataName_
};
Q.setDataName=function(a){
this.dataName_=a
};
Q.getDataPath=function(){
var a="";
if(this.parent_)a=this.parent_.getDataPath()+(this.dataName_[E]("[")!=-1?"":"/");
return a+this.dataName_
};
wa(Q,function(){
}
);
var jn=function(a,b){
hn[J](this,j,j,b);
this.uri_=a?new Sh(a):j
};
U(jn,hn);
Q=jn[y];
Q.loadState_="NOT_LOADED";
wa(Q,function(){
if(this.uri_){
Uf.info("Sending XML request for DataSource "+this.getDataName()+" to "+this.uri_);
this.loadState_="LOADING";
Rh(this.uri_,T(this.complete_,this))
}
else{
this.node_=Zl("nothing");
this.loadState_="NOT_LOADED"
}
}
);
Q.complete_=function(a){
(a=a[I])&&a.isSuccess()?this.success_(a):this.failure_()
};
Q.success_=function(a){
Uf.info("Got data for DataSource "+this.getDataName());
var b=a.getResponseXml();
if(b&&!b.hasChildNodes()&&Rd(a.getResponseText())){
a=a.getResponseText();
if(typeof DOMParser!="undefined")b=(new DOMParser).parseFromString(a,"application/xml");
else if(typeof ActiveXObject!="undefined"){
b=Yl();
b.loadXML(a);
b=b
}
else d(l("Your browser does not support loading xml documents"))
}
if(!b||!b.hasChildNodes()){
this.loadState_="FAILED";
this.node_=Zl("nothing")
}
else{
this.loadState_="LOADED";
this.node_=b[Dd]
}
this.getDataName()&&V().fireDataChange(this.getDataName())
};
Q.failure_=function(){
Uf.info("Data retrieve failed for DataSource "+this.getDataName());
this.loadState_="FAILED";
this.node_=Zl("nothing");
this.getDataName()&&V().fireDataChange(this.getDataName())
};
var kn=function(){
this.relativeTimeStart_=$d()
}
,ln=new kn;
kn[y].set=function(a){
this.relativeTimeStart_=a
};
Ta(kn[y],function(){
this.set($d())
}
);
kn[y].get=function(){
return this.relativeTimeStart_
};
var mn=function(a){
this.prefix_=a||"";
this.startTimeProvider_=ln
};
Q=mn[y];
Q.showAbsoluteTime=i;
Q.showRelativeTime=i;
Q.showLoggerName=i;
Q.showExceptionText=k;
Q.showSeverityLevel=k;
var on=function(a){
a=new Date(a.getMillis());
return nn(a[Fc]()-2E3)+nn(a[eb]()+1)+nn(a[Qb]())+" "+nn(a[id]())+":"+nn(a[jd]())+":"+nn(a[Cb]())+"."+nn(r[Gb](a.getMilliseconds()/10))
}
,nn=function(a){
if(a<10)return"0"+a;
return m(a)
}
,pn=function(a,b){
var c=a.getMillis()-b;
c=c/1E3;
var e=c.toFixed(3),f=0;
if(c<1)f=2;
else for(;
c<100;
){
f++;
c*=10
}
for(;
f-- >0;
)e=" "+e;
return e
}
,qn=function(a){
mn[J](this,a)
};
U(qn,mn);
qn[y].showExceptionText=i;
qn[y].formatRecord=function(a){
var b;
switch(a.getLevel()[D]){
case Df[D]:b="dbg-sh";
break;
case Ef[D]:b="dbg-sev";
break;
case Ff[D]:b="dbg-w";
break;
case Gf[D]:b="dbg-i";
break;
default:b="dbg-f"
}
var c=[];
c[w](this.prefix_," ");
this.showAbsoluteTime&&c[w]("[",on(a),"] ");
this.showRelativeTime&&c[w]("[",ue(pn(a,this.startTimeProvider_.get())),"s] ");
this.showLoggerName&&c[w]("[",se(a.getLoggerName()),"] ");
c[w]('<span class="',b,'">',me(ue(se(a.getMessage()))));
if(this.showExceptionText&&a.getException())c[w]("<br>",
me(ue(a.getExceptionText()||"")));
c[w]("</span><br>");
return c[ud]("")
};
var rn=function(a){
mn[J](this,a)
};
U(rn,mn);
rn[y].formatRecord=function(a){
var b=[];
b[w](this.prefix_," ");
this.showAbsoluteTime&&b[w]("[",on(a),"] ");
this.showRelativeTime&&b[w]("[",pn(a,this.startTimeProvider_.get()),"s] ");
this.showLoggerName&&b[w]("[",a.getLoggerName(),"] ");
this.showSeverityLevel&&b[w]("[",a.getLevel()[N],"] ");
b[w](a.getMessage(),"\n");
this.showExceptionText&&a.getException()&&b[w](a.getExceptionText(),"\n");
return b[ud]("")
};
var sn=function(){
this.publishHandler_=T(this.addLogRecord,this);
this.formatter_=new rn;
this.formatter_.showAbsoluteTime=k;
this.isCapturing_=this.formatter_.showExceptionText=k;
this.logBuffer_=""
};
sn[y].setCapturing=function(a){
if(a!=this.isCapturing_){
var b;
Nf();
b=Mf;
if(a)b.addHandler(this.publishHandler_);
else{
b.removeHandler(this.publishHandler_);
this.logBuffer=""
}
this.isCapturing_=a
}
};
sn[y].addLogRecord=function(a){
var b=this.formatter_.formatRecord(a);
if(p[Vc]&&p[Vc].firebug)switch(a.getLevel()){
case Df:p[Vc].info(b);
break;
case Ef:p[Vc].error(b);
break;
case Ff:p[Vc].warn(b);
break;
default:p[Vc].debug(b)
}
else if(p[Vc])p[Vc].log(b);
else if(p[vc])p[vc].postError(b);
else this.logBuffer_+=b
};
var tn=j;
var vn=function(a,b,c,e,f,g,h,n){
var o,s=c.offsetParent;
if(s){
var A=s[dd]=="HTML"||s[dd]=="BODY";
if(!A||Bj(s)!="static"){
o=Hj(s);
A||(o=li(o,new ki(s[Ic],s[bb])))
}
}
A=a;
s=Nj(A);
(A=Jj(A))&&s.intersection(new vj(A[ec],A.top,A[Fd]-A[ec],A[Nc]-A.top));
A=s=s;
var G=yi(a),R=yi(c);
if(G.getDocument()!=R.getDocument()){
var L=G.getDocument()[dc];
R=R.getWindow();
var Qa=new ki(0,0),Yd=Ii(xi(L)),Il=L;
do{
var rc;
if(Yd==R)rc=Hj(Il);
else{
var od=Il;
rc=new ki;
if(od[zb]==1)if(od[jb]){
var qh=Fj(od);
rc.x=qh[ec];
rc.y=qh.top
}
else{
qh=
yi(od).getDocumentScroll();
od=Hj(od);
rc.x=od.x-qh.x;
rc.y=od.y-qh.y
}
else{
rc.x=od[Bd];
rc.y=od[Cd]
}
rc=rc
}
rc=rc;
Qa.x+=rc.x;
Qa.y+=rc.y
}
while(Yd&&Yd!=R&&(Il=Yd.frameElement)&&(Yd=Yd[ic]));
R=Qa;
R=li(R,Hj(L));
if(X&&!G.isCss1CompatMode())R=li(R,G.getDocumentScroll());
A.left+=R.x;
A.top+=R.y
}
a=(b&4&&Ij(a)?b^2:b)&-5;
b=new ki(a&2?s[ec]+s[z]:s[ec],a&1?s.top+s[P]:s.top);
if(o)b=li(b,o);
if(f){
b.x+=(a&2?-1:1)*f.x;
b.y+=(a&1?-1:1)*f.y
}
var Ge;
if(h)if((Ge=Jj(c))&&o){
Ge.top=r.max(0,Ge.top-o.y);
Ge.right-=o.x;
Ge.bottom-=
o.y;
Da(Ge,r.max(0,Ge[ec]-o.x))
}
return un(b,c,e,g,Ge,h,n)
}
,un=function(a,b,c,e,f,g,h){
a=a.clone();
var n=0,o=(c&4&&Ij(b)?c^2:c)&-5;
c=Mj(b);
h=h?h.clone():c;
if(e||o!=0){
if(o&2)a.x-=h[z]+(e?e[Fd]:0);
else if(e)a.x+=e[ec];
if(o&1)a.y-=h[P]+(e?e[Nc]:0);
else if(e)a.y+=e.top
}
if(g){
if(f){
e=a;
n=h;
f=f;
g=g;
o=0;
if(e.x<f[ec]&&g&1){
e.x=f[ec];
o|=1
}
if(e.x<f[ec]&&e.x+n[z]>f[Fd]&&g&16){
n.width-=e.x+n[z]-f[Fd];
o|=4
}
if(e.x+n[z]>f[Fd]&&g&1){
e.x=r.max(f[Fd]-n[z],f[ec]);
o|=1
}
if(g&2)o|=(e.x<f[ec]?16:0)|(e.x+n[z]>f[Fd]?32:0);
if(e.y<f.top&&g&4){
e.y=f.top;
o|=2
}
if(e.y>=f.top&&e.y+n[P]>f[Nc]&&g&32){
n.height-=e.y+n[P]-f[Nc];
o|=8
}
if(e.y+n[P]>f[Nc]&&g&4){
e.y=r.max(f[Nc]-n[P],f.top);
o|=2
}
if(g&8)o|=(e.y<f.top?64:0)|(e.y+n[P]>f[Nc]?128:0);
g=o
}
else g=256;
n=g;
if(n&496)return n
}
Dj(b,a);
ni(c,h)||Lj(b,h);
return n
};
var wn=function(){
};
wn[y].reposition=function(){
};
var xn=function(a,b){
this.element=a;
this.corner=b
};
U(xn,wn);
xn[y].reposition=function(a,b,c){
vn(this.element,this.corner,a,b,ba,c)
};
var yn=function(a,b,c){
xn[J](this,a,b);
this.adjust_=c
};
U(yn,xn);
yn[y].reposition=function(a,b,c,e){
var f=vn(this.element,this.corner,a,b,j,c,10,e);
if(f&496){
var g=this.corner,h=b;
if(f&48){
g^=2;
h^=2
}
if(f&192){
g^=1;
h^=1
}
f=vn(this.element,g,a,h,j,c,10,e);
if(f&496)this.adjust_?vn(this.element,this.corner,a,b,j,c,5,e):vn(this.element,this.corner,a,b,j,c,0,e)
}
};
var zn=function(a,b,c,e){
yn[J](this,a,b,c);
this.resize_=e
};
U(zn,yn);
zn[y].reposition=function(a,b,c,e){
this.resize_?vn(this.element,this.corner,a,b,j,c,33,e):zn.superClass_.reposition[J](this,a,b,c,e)
};
var An=function(){
}
,Bn;
Kd(An);
Q=An[y];
Q.getAriaRole=function(){
};
Q.createDom=function(a){
return a.getDomHelper().createDom("div",this.getClassNames(a)[ud](" "),a.getContent())
};
Q.getContentElement=function(a){
return a
};
Q.enableClassName=function(a,b,c){
if(a=a.getElement?a.getElement():a)if(X&&!Dg("7")){
var e=this.getAppliedCombinedClassNames_(ti(a),b);
e[w](b);
c=c?ui:vi;
Zd(c,a)[$c](j,e)
}
else{
a=a;
b=b;
c?ui(a,b):vi(a,b)
}
};
Q.enableExtraClassName=function(a,b,c){
this.enableClassName(a,b,c)
};
Q.canDecorate=function(){
return i
};
Q.decorate=function(a,b){
b.id&&a.setId(b.id);
var c=this.getContentElement(b);
c&&c[Ec]?a.setContentInternal(c[Ec][md]?Ue(c[bd]):c[Ec]):a.setContentInternal(j);
var e=0,f=this.getCssClass(),g=this.getStructuralCssClass(),h=k,n=k;
c=k;
var o=ti(b);
Le(o,function(G){
if(!h&&G==f){
h=i;
if(g==f)n=i
}
else if(!n&&G==g)n=i;
else e|=this.getStateFromClass(G)
}
,this);
a.setStateInternal(e);
if(!h){
o[w](f);
if(g==f)n=i
}
n||o[w](g);
var s=a.getExtraClassNames();
s&&o[w][$c](o,s);
if(X&&!Dg("7")){
var A=this.getAppliedCombinedClassNames_(o);
if(A[x]>0){
o[w][$c](o,A);
c=i
}
}
if(!h||!n||s||c)si(b,o[ud](" "));
return b
};
Q.initializeDom=function(a){
a.isRightToLeft()&&this.setRightToLeft(a.getElement(),i);
a.isEnabled()&&this.setFocusable(a,a.isVisible())
};
Q.setAriaRole=function(a){
var b=this.getAriaRole();
b&&dj(a,b)
};
Q.setAllowTextSelection=function(a,b){
Sj(a,!b,!X&&!lg)
};
Q.setRightToLeft=function(a,b){
this.enableClassName(a,this.getStructuralCssClass()+"-rtl",b)
};
Q.isFocusable=function(a){
var b;
if(a.isSupportedState(32)&&(b=a.getKeyEventTarget()))return Zi(b);
return k
};
Q.setFocusable=function(a,b){
var c;
if(a.isSupportedState(32)&&(c=a.getKeyEventTarget())){
if(!b&&a.isFocused()){
try{
c[Mb]()
}
catch(e){
}
a.isFocused()&&a.handleBlur(j)
}
if(Zi(c)!=b){
c=c;
if(b)c.tabIndex=0;
else c.removeAttribute("tabIndex")
}
}
};
Q.setVisible=function(a,b){
Qj(a,b)
};
Q.setState=function(a,b,c){
var e=a.getElement();
if(e){
var f=this.getClassForState(b);
f&&this.enableClassName(a,f,c);
this.updateAriaState(e,b,c)
}
};
Q.updateAriaState=function(a,b,c){
if(mg){
Bn||(Bn=nf(1,"disabled",4,"pressed",8,"selected",16,"checked",64,"expanded"));
(b=Bn[b])&&ej(a,b,c)
}
};
Q.setContent=function(a,b){
var c=this.getContentElement(a);
if(c){
Qi(c);
if(b)if(Od(b))Wi(c,b);
else{
var e=function(f){
if(f){
var g=xi(c);
c[v](Od(f)?g[Nb](f):f)
}
};
if(Md(b))Le(b,e);
else Nd(b)&&!("nodeType"in b)?Le(Ue(b),e):e(b)
}
}
};
Q.getKeyEventTarget=function(a){
return a.getElement()
};
Q.getCssClass=function(){
return"goog-control"
};
Q.getIe6ClassCombinations=function(){
return[]
};
Q.getStructuralCssClass=function(){
return this.getCssClass()
};
Q.getClassNames=function(a){
var b=this.getCssClass(),c=[b],e=this.getStructuralCssClass();
e!=b&&c[w](e);
b=this.getClassNamesForState(a.getState());
c[w][$c](c,b);
(a=a.getExtraClassNames())&&c[w][$c](c,a);
X&&!Dg("7")&&c[w][$c](c,this.getAppliedCombinedClassNames_(c));
return c
};
Q.getAppliedCombinedClassNames_=function(a,b){
var c=[];
if(b)a=a[Kb]([b]);
Le(this.getIe6ClassCombinations(),function(e){
if(Oe(e,Zd(Qe,a))&&(!b||Qe(e,b)))c[w](e[ud]("_"))
}
);
return c
};
Q.getClassNamesForState=function(a){
for(var b=[];
a;
){
var c=a&-a;
b[w](this.getClassForState(c));
a&=~c
}
return b
};
Q.getClassForState=function(a){
this.classByState_||this.createClassByStateMap_();
return this.classByState_[a]
};
Q.getStateFromClass=function(a){
this.stateByClass_||this.createStateByClassMap_();
a=da(this.stateByClass_[a],10);
return ia(a)?0:a
};
Q.createClassByStateMap_=function(){
var a=this.getStructuralCssClass();
this.classByState_=nf(1,a+"-disabled",2,a+"-hover",4,a+"-active",8,a+"-selected",16,a+"-checked",32,a+"-focused",64,a+"-open")
};
Q.createStateByClassMap_=function(){
this.classByState_||this.createClassByStateMap_();
var a;
a=this.classByState_;
var b={
}
,c;
for(c in a)b[a[c]]=c;
this.stateByClass_=a=b
};
var Cn=function(){
};
U(Cn,An);
Kd(Cn);
Q=Cn[y];
Q.getAriaRole=function(){
return"button"
};
Q.updateAriaState=function(a,b,c){
if(mg)b==16?ej(a,"pressed",c):Cn.superClass_.updateAriaState[J](this,a,b,c)
};
Q.createDom=function(a){
var b=Cn.superClass_.createDom[J](this,a),c=a.getTooltip();
c&&this.setTooltip(b,c);
(c=a.getValue())&&this.setValue(b,c);
a.isSupportedState(16)&&this.updateAriaState(b,16,k);
return b
};
Q.decorate=function(a,b){
b=Cn.superClass_.decorate[J](this,a,b);
a.setValueInternal(this.getValue(b));
a.setTooltipInternal(this.getTooltip(b));
a.isSupportedState(16)&&this.updateAriaState(b,16,k);
return b
};
Q.getValue=Jd;
Q.setValue=Jd;
Q.getTooltip=function(a){
return a[ib]
};
Q.setTooltip=function(a,b){
if(a)qa(a,b||"")
};
Q.getCssClass=function(){
return"goog-button"
};
var En=function(a,b){
if(!a)d(l("Invalid class name "+a));
if(!Qd(b))d(l("Invalid decorator function "+b));
Dn[a]=b
}
,Fn=function(a){
for(var b=ti(a),c=0,e=b[x];
c<e;
c++)if(a=b[c]in Dn?Dn[b[c]]():j)return a;
return j
}
,Gn={
}
,Dn={
};
var Hn=function(a){
var b=Fn(a);
b&&b.decorate(a);
return b
};
var In=function(a,b,c){
Dk[J](this,c);
if(!(b=b)){
b=this.constructor;
for(var e;
b;
){
e=Ud(b);
if(e=Gn[e])break;
b=b.superClass_?b.superClass_.constructor:j
}
b=e?Qd(e.getInstance)?e.getInstance():new e:j
}
this.renderer_=b;
this.setContentInternal(a)
};
U(In,Dk);
var Jn=Hn;
Q=In[y];
Q.content_=j;
Q.state_=0;
Q.supportedStates_=39;
Q.autoStates_=255;
Q.statesWithTransitionEvents_=0;
Q.visible_=i;
Q.extraClassNames_=j;
Q.handleMouseEvents_=i;
Q.allowTextSelection_=k;
Q.isHandleMouseEvents=function(){
return this.handleMouseEvents_
};
Q.setHandleMouseEvents=function(a){
this.isInDocument()&&a!=this.handleMouseEvents_&&this.enableMouseEventHandling_(a);
this.handleMouseEvents_=a
};
Q.getKeyEventTarget=function(){
return this.renderer_.getKeyEventTarget(this)
};
Q.getKeyHandler=function(){
return this.keyHandler_||(this.keyHandler_=new nj)
};
Q.getRenderer=function(){
return this.renderer_
};
Q.getExtraClassNames=function(){
return this.extraClassNames_
};
Q.addClassName=function(a){
if(a){
if(this.extraClassNames_)Qe(this.extraClassNames_,a)||this.extraClassNames_[w](a);
else this.extraClassNames_=[a];
this.renderer_.enableExtraClassName(this,a,i)
}
};
Q.removeClassName=function(a){
if(a&&this.extraClassNames_){
Se(this.extraClassNames_,a);
if(this.extraClassNames_[x]==0)this.extraClassNames_=j;
this.renderer_.enableExtraClassName(this,a,k)
}
};
Q.enableClassName=function(a,b){
b?this.addClassName(a):this.removeClassName(a)
};
Q.createDom=function(){
var a=this.renderer_.createDom(this);
this.setElementInternal(a);
this.renderer_.setAriaRole(a);
this.isAllowTextSelection()||this.renderer_.setAllowTextSelection(a,k);
this.isVisible()||this.renderer_.setVisible(a,k)
};
Q.getContentElement=function(){
return this.renderer_.getContentElement(this.getElement())
};
Q.canDecorate=function(a){
return this.renderer_.canDecorate(a)
};
Q.decorateInternal=function(a){
a=this.renderer_.decorate(this,a);
this.setElementInternal(a);
this.renderer_.setAriaRole(a);
this.isAllowTextSelection()||this.renderer_.setAllowTextSelection(a,k);
this.visible_=a[H][ld]!="none"
};
Q.enterDocument=function(){
In.superClass_.enterDocument[J](this);
this.renderer_.initializeDom(this);
if(this.supportedStates_&-2){
this.isHandleMouseEvents()&&this.enableMouseEventHandling_(i);
if(this.isSupportedState(32)){
var a=this.getKeyEventTarget();
if(a){
var b=this.getKeyHandler();
b.attach(a);
this.getHandler().listen(b,"key",this.handleKeyEvent).listen(a,"focus",this.handleFocus).listen(a,"blur",this.handleBlur)
}
}
}
};
Q.enableMouseEventHandling_=function(a){
var b=this.getHandler(),c=this.getElement();
if(a){
b.listen(c,"mouseover",this.handleMouseOver).listen(c,"mousedown",this.handleMouseDown).listen(c,"mouseup",this.handleMouseUp).listen(c,"mouseout",this.handleMouseOut);
X&&b.listen(c,"dblclick",this.handleDblClick)
}
else{
b.unlisten(c,"mouseover",this.handleMouseOver).unlisten(c,"mousedown",this.handleMouseDown).unlisten(c,"mouseup",this.handleMouseUp).unlisten(c,"mouseout",this.handleMouseOut);
X&&b.unlisten(c,
"dblclick",this.handleDblClick)
}
};
Q.exitDocument=function(){
In.superClass_.exitDocument[J](this);
this.keyHandler_&&this.keyHandler_[Xc]();
this.isVisible()&&this.isEnabled()&&this.renderer_.setFocusable(this,k)
};
Q.disposeInternal=function(){
In.superClass_.disposeInternal[J](this);
if(this.keyHandler_){
this.keyHandler_.dispose();
delete this.keyHandler_
}
delete this.renderer_;
this.extraClassNames_=this.content_=j
};
Q.getContent=function(){
return this.content_
};
Q.setContent=function(a){
this.renderer_.setContent(this.getElement(),a);
this.setContentInternal(a)
};
Q.setContentInternal=function(a){
this.content_=a
};
Q.getCaptionInternal=function(a){
var b=this.getContent();
if(!b||Od(b))return b;
return(a=Md(b)?Ne(b,a)[ud](""):aj(b))&&je(a)
};
Q.getCaption=function(){
return this.getCaptionInternal(aj)
};
Q.setCaption=function(a){
this.setContent(a)
};
Q.setRightToLeft=function(a){
In.superClass_.setRightToLeft[J](this,a);
var b=this.getElement();
b&&this.renderer_.setRightToLeft(b,a)
};
Q.isAllowTextSelection=function(){
return this.allowTextSelection_
};
Q.setAllowTextSelection=function(a){
this.allowTextSelection_=a;
var b=this.getElement();
b&&this.renderer_.setAllowTextSelection(b,a)
};
Q.isVisible=function(){
return this.visible_
};
Q.setVisible=function(a,b){
if(b||this.visible_!=a&&this[F](a?"show":"hide")){
var c=this.getElement();
c&&this.renderer_.setVisible(c,a);
this.isEnabled()&&this.renderer_.setFocusable(this,a);
this.visible_=a;
return i
}
return k
};
Q.isEnabled=function(){
return!this.hasState(1)
};
Q.isParentDisabled_=function(){
var a=this.getParent();
return!!a&&typeof a.isEnabled=="function"&&!a.isEnabled()
};
Q.setEnabled=function(a){
if(!this.isParentDisabled_()&&this.isTransitionAllowed(1,!a)){
if(!a){
this[wd](k);
this.setHighlighted(k)
}
this.isVisible()&&this.renderer_.setFocusable(this,a);
this.setState(1,!a)
}
};
Q.setHighlighted=function(a){
this.isTransitionAllowed(2,a)&&this.setState(2,a)
};
Q.isActive=function(){
return this.hasState(4)
};
Q.setActive=function(a){
this.isTransitionAllowed(4,a)&&this.setState(4,a)
};
Q.isSelected=function(){
return this.hasState(8)
};
Q.setSelected=function(a){
this.isTransitionAllowed(8,a)&&this.setState(8,a)
};
Q.isChecked=function(){
return this.hasState(16)
};
Q.setChecked=function(a){
this.isTransitionAllowed(16,a)&&this.setState(16,a)
};
Q.isFocused=function(){
return this.hasState(32)
};
Q.setFocused=function(a){
this.isTransitionAllowed(32,a)&&this.setState(32,a)
};
Q.isOpen=function(){
return this.hasState(64)
};
Q.setOpen=function(a){
this.isTransitionAllowed(64,a)&&this.setState(64,a)
};
Q.getState=function(){
return this.state_
};
Q.hasState=function(a){
return!!(this.state_&a)
};
Q.setState=function(a,b){
if(this.isSupportedState(a)&&b!=this.hasState(a)){
this.renderer_.setState(this,a,b);
this.state_=b?this.state_|a:this.state_&~a
}
};
Q.setStateInternal=function(a){
this.state_=a
};
Q.isSupportedState=function(a){
return!!(this.supportedStates_&a)
};
Q.setSupportedState=function(a,b){
if(this.isInDocument()&&this.hasState(a)&&!b)d(l("Component already rendered"));
!b&&this.hasState(a)&&this.setState(a,k);
this.supportedStates_=b?this.supportedStates_|a:this.supportedStates_&~a
};
Q.isAutoState=function(a){
return!!(this.autoStates_&a)&&this.isSupportedState(a)
};
Q.setAutoStates=function(a,b){
this.autoStates_=b?this.autoStates_|a:this.autoStates_&~a
};
Q.setDispatchTransitionEvents=function(a,b){
this.statesWithTransitionEvents_=b?this.statesWithTransitionEvents_|a:this.statesWithTransitionEvents_&~a
};
Q.isTransitionAllowed=function(a,b){
return this.isSupportedState(a)&&this.hasState(a)!=b&&(!(this.statesWithTransitionEvents_&a)||this[F](Fk(a,b)))&&!this.isDisposed()
};
Q.handleMouseOver=function(a){
!Kn(a,this.getElement())&&this[F]("enter")&&this.isEnabled()&&this.isAutoState(2)&&this.setHighlighted(i)
};
Q.handleMouseOut=function(a){
if(!Kn(a,this.getElement())&&this[F]("leave")){
this.isAutoState(4)&&this[wd](k);
this.isAutoState(2)&&this.setHighlighted(k)
}
};
var Kn=function(a,b){
return!!a[nb]&&Ui(b,a[nb])
};
Q=In[y];
Q.handleMouseDown=function(a){
if(this.isEnabled()){
this.isAutoState(2)&&this.setHighlighted(i);
if(a.isButton(0)){
this.isAutoState(4)&&this[wd](i);
this.renderer_.isFocusable(this)&&this.getKeyEventTarget()[zc]()
}
}
!this.isAllowTextSelection()&&a.isButton(0)&&a[Sb]()
};
Q.handleMouseUp=function(a){
if(this.isEnabled()){
this.isAutoState(2)&&this.setHighlighted(i);
this.isActive()&&this.performActionInternal(a)&&this.isAutoState(4)&&this[wd](k)
}
};
Q.handleDblClick=function(a){
this.isEnabled()&&this.performActionInternal(a)
};
Q.performActionInternal=function(a){
this.isAutoState(16)&&this.setChecked(!this.isChecked());
this.isAutoState(8)&&this.setSelected(i);
this.isAutoState(64)&&this.setOpen(!this[qc]());
var b=new Ig("action",this);
if(a)for(var c=["altKey","ctrlKey","metaKey","shiftKey","platformModifierKey"],e,f=0;
e=c[f];
f++)b[e]=a[e];
return this[F](b)
};
Q.handleFocus=function(){
this.isAutoState(32)&&this.setFocused(i)
};
Q.handleBlur=function(){
this.isAutoState(4)&&this[wd](k);
this.isAutoState(32)&&this.setFocused(k)
};
Q.handleKeyEvent=function(a){
if(this.isVisible()&&this.isEnabled()&&this.handleKeyEventInternal(a)){
a[Sb]();
a[Ob]();
return i
}
return k
};
Q.handleKeyEventInternal=function(a){
return a[Dc]==13&&this.performActionInternal(a)
};
var Ln=In,Mn=An;
if(!Qd(Ln))d(l("Invalid component class "+Ln));
if(!Qd(Mn))d(l("Invalid renderer class "+Mn));
var Nn=Ud(Ln);
Gn[Nn]=Mn;
En("goog-control",function(){
return new In(j)
}
);
var On=function(){
};
U(On,Cn);
Kd(On);
Q=On[y];
Q.getAriaRole=function(){
};
Q.createDom=function(a){
this.setUpNativeButton_(a);
return a.getDomHelper().createDom("button",{
"class":this.getClassNames(a)[ud](" "),disabled:!a.isEnabled(),title:a.getTooltip()||"",value:a.getValue()||""
}
,a.getCaption()||"")
};
Q.canDecorate=function(a){
return a[dd]=="BUTTON"||a[dd]=="INPUT"&&(a[Zc]=="button"||a[Zc]=="submit"||a[Zc]=="reset")
};
Q.decorate=function(a,b){
this.setUpNativeButton_(a);
b[Xb]&&ui(b,this.getClassForState(1));
return On.superClass_.decorate[J](this,a,b)
};
Q.initializeDom=function(a){
a.getHandler().listen(a.getElement(),"click",a.performActionInternal)
};
Q.setAllowTextSelection=Jd;
Q.setRightToLeft=Jd;
Q.isFocusable=function(a){
return a.isEnabled()
};
Q.setFocusable=Jd;
Q.setState=function(a,b,c){
On.superClass_.setState[J](this,a,b,c);
if((a=a.getElement())&&b==1)Aa(a,c)
};
Q.getValue=function(a){
return a[D]
};
Q.setValue=function(a,b){
if(a)za(a,b)
};
Q.updateAriaState=Jd;
Q.setUpNativeButton_=function(a){
a.setHandleMouseEvents(k);
a.setAutoStates(255,k);
a.setSupportedState(32,k)
};
var Pn=function(a,b,c){
In[J](this,a,b||On.getInstance(),c)
};
U(Pn,In);
Q=Pn[y];
Q.getValue=function(){
return this.value_
};
Q.setValue=function(a){
this.value_=a;
this.getRenderer().setValue(this.getElement(),a)
};
Q.setValueInternal=function(a){
this.value_=a
};
Q.getTooltip=function(){
return this.tooltip_
};
Q.setTooltip=function(a){
this.tooltip_=a;
this.getRenderer().setTooltip(this.getElement(),a)
};
Q.setTooltipInternal=function(a){
this.tooltip_=a
};
Q.disposeInternal=function(){
Pn.superClass_.disposeInternal[J](this);
delete this.value_;
delete this.tooltip_
};
Q.enterDocument=function(){
Pn.superClass_.enterDocument[J](this);
if(this.isSupportedState(32)){
var a=this.getKeyEventTarget();
a&&this.getHandler().listen(a,"keyup",this.handleKeyEventInternal)
}
};
Q.handleKeyEventInternal=function(a){
if(a[Dc]==13&&a[Zc]=="key"||a[Dc]==32&&a[Zc]=="keyup")return this.performActionInternal(a);
return a[Dc]==32
};
En("goog-button",function(){
return new Pn(j)
}
);
var Qn=function(){
};
U(Qn,An);
Kd(Qn);
Qn[y].createDom=function(a){
return a.getDomHelper().createDom("div",this.getCssClass())
};
Qn[y].decorate=function(a,b){
if(b[dd]=="HR"){
var c=b;
b=this.createDom(a);
c[O]&&c[O][Ub](b,c);
Ri(c)
}
else ui(b,this.getCssClass());
return b
};
Qn[y].setContent=function(){
};
Qn[y].getCssClass=function(){
return"goog-menuseparator"
};
var Rn=function(a,b){
In[J](this,j,a||Qn.getInstance(),b);
this.setSupportedState(1,k);
this.setSupportedState(2,k);
this.setSupportedState(4,k);
this.setSupportedState(32,k);
this.setStateInternal(1)
};
U(Rn,In);
Rn[y].enterDocument=function(){
Rn.superClass_.enterDocument[J](this);
dj(this.getElement(),"separator")
};
En("goog-menuseparator",function(){
return new Rn
}
);
var Sn=function(){
};
Kd(Sn);
Q=Sn[y];
Q.getAriaRole=function(){
};
Q.enableTabIndex=function(a,b){
if(a)a.tabIndex=b?0:-1
};
Q.createDom=function(a){
return a.getDomHelper().createDom("div",this.getClassNames(a)[ud](" "))
};
Q.getContentElement=function(a){
return a
};
Q.canDecorate=function(a){
return a[dd]=="DIV"
};
Q.decorate=function(a,b){
b.id&&a.setId(b.id);
var c=this.getCssClass(),e=k,f=ti(b);
f&&Le(f,function(g){
if(g==c)e=i;
else g&&this.setStateFromClassName(a,g,c)
}
,this);
e||ui(b,c);
this.decorateChildren(a,this.getContentElement(b));
return b
};
Q.setStateFromClassName=function(a,b,c){
if(b==c+"-disabled")a.setEnabled(k);
else if(b==c+"-horizontal")a.setOrientation("horizontal");
else b==c+"-vertical"&&a.setOrientation("vertical")
};
Q.decorateChildren=function(a,b,c){
if(b){
c=c||b[Ec];
for(var e;
c&&c[O]==b;
){
e=c[md];
if(c[zb]==1){
var f=this.getDecoratorForChild(c);
if(f){
f.setElementInternal(c);
a.isEnabled()||f.setEnabled(k);
a.addChild(f);
f.decorate(c)
}
}
else if(!c[yd]||je(c[yd])=="")b[hc](c);
c=e
}
}
};
Q.getDecoratorForChild=function(a){
return Fn(a)
};
Q.initializeDom=function(a){
a=a.getElement();
Sj(a,i,mg);
if(X)a.hideFocus=i;
var b=this.getAriaRole();
b&&dj(a,b)
};
Q.getKeyEventTarget=function(a){
return a.getElement()
};
Q.getCssClass=function(){
return"goog-container"
};
Q.getClassNames=function(a){
var b=this.getCssClass(),c=a.getOrientation()=="horizontal";
c=[b,c?b+"-horizontal":b+"-vertical"];
a.isEnabled()||c[w](b+"-disabled");
return c
};
Q.getDefaultOrientation=function(){
return"vertical"
};
var Tn=function(a,b,c){
Dk[J](this,c);
this.renderer_=b||Sn.getInstance();
this.orientation_=a||this.renderer_.getDefaultOrientation()
};
U(Tn,Dk);
Q=Tn[y];
Q.keyEventTarget_=j;
Q.keyHandler_=j;
Q.renderer_=j;
Q.orientation_=j;
Q.visible_=i;
Q.enabled_=i;
Q.focusable_=i;
Q.highlightedIndex_=-1;
Q.openItem_=j;
Q.mouseButtonPressed_=k;
Q.allowFocusableChildren_=k;
Q.openFollowsHighlight_=i;
Q.childElementIdMap_=j;
Q.getKeyEventTarget=function(){
return this.keyEventTarget_||this.renderer_.getKeyEventTarget(this)
};
Q.getKeyHandler=function(){
return this.keyHandler_||(this.keyHandler_=new nj(this.getKeyEventTarget()))
};
Q.getRenderer=function(){
return this.renderer_
};
Q.createDom=function(){
this.setElementInternal(this.renderer_.createDom(this))
};
Q.getContentElement=function(){
return this.renderer_.getContentElement(this.getElement())
};
Q.canDecorate=function(a){
return this.renderer_.canDecorate(a)
};
Q.decorateInternal=function(a){
this.setElementInternal(this.renderer_.decorate(this,a));
if(a[H][ld]=="none")this.visible_=k
};
Q.enterDocument=function(){
Tn.superClass_.enterDocument[J](this);
this.forEachChild(function(b){
b.isInDocument()&&this.registerChildId_(b)
}
,this);
var a=this.getElement();
this.renderer_.initializeDom(this);
this.setVisible(this.visible_,i);
this.getHandler().listen(this,"enter",this.handleEnterItem).listen(this,"highlight",this.handleHighlightItem).listen(this,"unhighlight",this.handleUnHighlightItem).listen(this,"open",this.handleOpenItem).listen(this,"close",this.handleCloseItem).listen(a,"mousedown",
this.handleMouseDown).listen(xi(a),"mouseup",this.handleDocumentMouseUp).listen(a,["mousedown","mouseup","mouseover","mouseout"],this.handleChildMouseEvents);
this.isFocusable()&&this.enableFocusHandling_(i)
};
Q.enableFocusHandling_=function(a){
var b=this.getHandler(),c=this.getKeyEventTarget();
a?b.listen(c,"focus",this.handleFocus).listen(c,"blur",this.handleBlur).listen(this.getKeyHandler(),"key",this.handleKeyEvent):b.unlisten(c,"focus",this.handleFocus).unlisten(c,"blur",this.handleBlur).unlisten(this.getKeyHandler(),"key",this.handleKeyEvent)
};
Q.exitDocument=function(){
this.setHighlightedIndex(-1);
this.openItem_&&this.openItem_.setOpen(k);
this.mouseButtonPressed_=k;
Tn.superClass_.exitDocument[J](this)
};
Q.disposeInternal=function(){
Tn.superClass_.disposeInternal[J](this);
if(this.keyHandler_){
this.keyHandler_.dispose();
this.keyHandler_=j
}
this.renderer_=this.openItem_=this.childElementIdMap_=j
};
Q.handleEnterItem=function(){
return i
};
Q.handleHighlightItem=function(a){
var b=this.indexOfChild(a[I]);
if(b>-1&&b!=this.highlightedIndex_){
var c=this.getHighlighted();
c&&c.setHighlighted(k);
this.highlightedIndex_=b;
c=this.getHighlighted();
this.isMouseButtonPressed()&&c[wd](i);
if(this.openFollowsHighlight_&&this.openItem_&&c!=this.openItem_)c.isSupportedState(64)?c.setOpen(i):this.openItem_.setOpen(k)
}
ej(this.getElement(),"activedescendant",a[I].getElement().id)
};
Q.handleUnHighlightItem=function(a){
if(a[I]==this.getHighlighted())this.highlightedIndex_=-1;
ej(this.getElement(),"activedescendant","")
};
Q.handleOpenItem=function(a){
if((a=a[I])&&a!=this.openItem_&&a.getParent()==this){
this.openItem_&&this.openItem_.setOpen(k);
this.openItem_=a
}
};
Q.handleCloseItem=function(a){
if(a[I]==this.openItem_)this.openItem_=j
};
Q.handleMouseDown=function(a){
this.enabled_&&this.setMouseButtonPressed(i);
var b=this.getKeyEventTarget();
b&&Zi(b)?b[zc]():a[Sb]()
};
Q.handleDocumentMouseUp=function(){
this.setMouseButtonPressed(k)
};
Q.handleChildMouseEvents=function(a){
var b=this.getOwnerControl(a[I]);
if(b)switch(a[Zc]){
case "mousedown":b.handleMouseDown(a);
break;
case "mouseup":b.handleMouseUp(a);
break;
case "mouseover":b.handleMouseOver(a);
break;
case "mouseout":b.handleMouseOut(a)
}
};
Q.getOwnerControl=function(a){
if(this.childElementIdMap_)for(var b=this.getElement();
a&&a!==b;
){
var c=a.id;
if(c in this.childElementIdMap_)return this.childElementIdMap_[c];
a=a[O]
}
return j
};
Q.handleFocus=function(){
};
Q.handleBlur=function(){
this.setHighlightedIndex(-1);
this.setMouseButtonPressed(k);
this.openItem_&&this.openItem_.setOpen(k)
};
Q.handleKeyEvent=function(a){
if(this.isEnabled()&&this.isVisible()&&(this.getChildCount()!=0||this.keyEventTarget_)&&this.handleKeyEventInternal(a)){
a[Sb]();
a[Ob]();
return i
}
return k
};
Q.handleKeyEventInternal=function(a){
var b=this.getHighlighted();
if(b&&typeof b.handleKeyEvent=="function"&&b.handleKeyEvent(a))return i;
if(this.openItem_&&this.openItem_!=b&&typeof this.openItem_.handleKeyEvent=="function"&&this.openItem_.handleKeyEvent(a))return i;
if(a[cd]||a[Db]||a[Wb]||a[fb])return k;
switch(a[Dc]){
case 27:if(this.isFocusable())this.getKeyEventTarget()[Mb]();
else return k;
break;
case 36:this.highlightFirst();
break;
case 35:this.highlightLast();
break;
case 38:if(this.orientation_==
"vertical")this.highlightPrevious();
else return k;
break;
case 37:if(this.orientation_=="horizontal")this.isRightToLeft()?this.highlightNext():this.highlightPrevious();
else return k;
break;
case 40:if(this.orientation_=="vertical")this.highlightNext();
else return k;
break;
case 39:if(this.orientation_=="horizontal")this.isRightToLeft()?this.highlightPrevious():this.highlightNext();
else return k;
break;
default:return k
}
return i
};
Q.registerChildId_=function(a){
var b=a.getElement();
b=b.id||(b.id=a.getId());
if(!this.childElementIdMap_)this.childElementIdMap_={
};
this.childElementIdMap_[b]=a
};
Q.addChild=function(a,b){
Tn.superClass_.addChild[J](this,a,b)
};
Q.addChildAt=function(a,b,c){
a.setDispatchTransitionEvents(2,i);
a.setDispatchTransitionEvents(64,i);
if(this.isFocusable()||!this.isFocusableChildrenAllowed())a.setSupportedState(32,k);
a.setHandleMouseEvents(k);
Tn.superClass_.addChildAt[J](this,a,b,c);
c&&this.isInDocument()&&this.registerChildId_(a);
b<=this.highlightedIndex_&&this.highlightedIndex_++
};
Q.removeChild=function(a,b){
if(a=Od(a)?this.getChild(a):a){
var c=this.indexOfChild(a);
if(c!=-1)if(c==this.highlightedIndex_)a.setHighlighted(k);
else c<this.highlightedIndex_&&this.highlightedIndex_--;
(c=a.getElement())&&c.id&&hf(this.childElementIdMap_,c.id)
}
a=Tn.superClass_[hc][J](this,a,b);
a.setHandleMouseEvents(i);
return a
};
Q.getOrientation=function(){
return this.orientation_
};
Q.setOrientation=function(a){
if(this.getElement())d(l("Component already rendered"));
this.orientation_=a
};
Q.isVisible=function(){
return this.visible_
};
Q.setVisible=function(a,b){
if(b||this.visible_!=a&&this[F](a?"show":"hide")){
this.visible_=a;
var c=this.getElement();
if(c){
Qj(c,a);
this.isFocusable()&&this.renderer_.enableTabIndex(this.getKeyEventTarget(),this.enabled_&&this.visible_);
b||this[F](this.visible_?"aftershow":"afterhide")
}
return i
}
return k
};
Q.isEnabled=function(){
return this.enabled_
};
Q.setEnabled=function(a){
if(this.enabled_!=a&&this[F](a?"enable":"disable")){
if(a){
this.enabled_=i;
this.forEachChild(function(b){
if(b.wasDisabled)delete b.wasDisabled;
else b.setEnabled(i)
}
)
}
else{
this.forEachChild(function(b){
if(b.isEnabled())b.setEnabled(k);
else b.wasDisabled=i
}
);
this.enabled_=k;
this.setMouseButtonPressed(k)
}
this.isFocusable()&&this.renderer_.enableTabIndex(this.getKeyEventTarget(),a&&this.visible_)
}
};
Q.isFocusable=function(){
return this.focusable_
};
Q.setFocusable=function(a){
a!=this.focusable_&&this.isInDocument()&&this.enableFocusHandling_(a);
this.focusable_=a;
this.enabled_&&this.visible_&&this.renderer_.enableTabIndex(this.getKeyEventTarget(),a)
};
Q.isFocusableChildrenAllowed=function(){
return this.allowFocusableChildren_
};
Q.setHighlightedIndex=function(a){
if(a=this.getChildAt(a))a.setHighlighted(i);
else this.highlightedIndex_>-1&&this.getHighlighted().setHighlighted(k)
};
Q.setHighlighted=function(a){
this.setHighlightedIndex(this.indexOfChild(a))
};
Q.getHighlighted=function(){
return this.getChildAt(this.highlightedIndex_)
};
Q.highlightFirst=function(){
this.highlightHelper(function(a,b){
return(a+1)%b
}
,this.getChildCount()-1)
};
Q.highlightLast=function(){
this.highlightHelper(function(a,b){
a--;
return a<0?b-1:a
}
,0)
};
Q.highlightNext=function(){
this.highlightHelper(function(a,b){
return(a+1)%b
}
,this.highlightedIndex_)
};
Q.highlightPrevious=function(){
this.highlightHelper(function(a,b){
a--;
return a<0?b-1:a
}
,this.highlightedIndex_)
};
Q.highlightHelper=function(a,b){
var c=b<0?this.indexOfChild(this.openItem_):b,e=this.getChildCount();
c=a[J](this,c,e);
for(var f=0;
f<=e;
){
var g=this.getChildAt(c);
if(g&&this.canHighlightItem(g)){
this.setHighlightedIndexFromKeyEvent(c);
return i
}
f++;
c=a[J](this,c,e)
}
return k
};
Q.canHighlightItem=function(a){
return a.isVisible()&&a.isEnabled()&&a.isSupportedState(2)
};
Q.setHighlightedIndexFromKeyEvent=function(a){
this.setHighlightedIndex(a)
};
Q.isMouseButtonPressed=function(){
return this.mouseButtonPressed_
};
Q.setMouseButtonPressed=function(a){
this.mouseButtonPressed_=a
};
var Un=function(){
};
U(Un,An);
Kd(Un);
Un[y].getCssClass=function(){
return"goog-menuheader"
};
var Vn=function(a,b,c){
In[J](this,a,c||Un.getInstance(),b);
this.setSupportedState(1,k);
this.setSupportedState(2,k);
this.setSupportedState(4,k);
this.setSupportedState(32,k);
this.setStateInternal(1)
};
U(Vn,In);
En("goog-menuheader",function(){
return new Vn(j)
}
);
var Wn=function(){
this.classNameCache_=[]
};
U(Wn,An);
Kd(Wn);
Q=Wn[y];
Q.getCompositeCssClass_=function(a){
var b=this.classNameCache_[a];
if(!b){
switch(a){
case 0:b=this.getStructuralCssClass()+"-highlight";
break;
case 1:b=this.getStructuralCssClass()+"-checkbox";
break;
case 2:b=this.getStructuralCssClass()+"-content"
}
this.classNameCache_[a]=b
}
return b
};
Q.getAriaRole=function(){
return"menuitem"
};
Q.createDom=function(a){
var b=a.getDomHelper().createDom("div",this.getClassNames(a)[ud](" "),this.createContent(a.getContent(),a.getDomHelper()));
this.setEnableCheckBoxStructure(a,b,a.isSupportedState(8)||a.isSupportedState(16));
return b
};
Q.getContentElement=function(a){
return a&&a[Ec]
};
Q.decorate=function(a,b){
this.hasContentStructure(b)||b[v](this.createContent(b[bd],a.getDomHelper()));
if(Qe(ti(b),"goog-option")){
a.setCheckable(i);
this.setCheckable(a,b,i)
}
return Wn.superClass_.decorate[J](this,a,b)
};
Q.setContent=function(a,b){
var c=this.getContentElement(a),e=this.hasCheckBoxStructure(a)?c[Ec]:j;
Wn.superClass_.setContent[J](this,a,b);
if(e&&!this.hasCheckBoxStructure(a))c[Ub](e,c[Ec]||j)
};
Q.hasContentStructure=function(a){
a=Ti(a);
var b=this.getCompositeCssClass_(2);
return!!a&&a[ob][E](b)!=-1
};
Q.createContent=function(a,b){
var c=this.getCompositeCssClass_(2);
return b.createDom("div",c,a)
};
Q.setCheckable=function(a,b,c){
if(b){
dj(b,c?"menuitemcheckbox":this.getAriaRole());
this.setEnableCheckBoxStructure(a,b,c)
}
};
Q.hasCheckBoxStructure=function(a){
if(a=this.getContentElement(a)){
a=a[Ec];
var b=this.getCompositeCssClass_(1);
return!!a&&!!a[ob]&&a[ob][E](b)!=-1
}
return k
};
Q.setEnableCheckBoxStructure=function(a,b,c){
if(c!=this.hasCheckBoxStructure(b)){
var e=b,f="goog-option";
c?ui(e,f):vi(e,f);
b=this.getContentElement(b);
if(c){
c=this.getCompositeCssClass_(1);
b[Ub](a.getDomHelper().createDom("div",c),b[Ec]||j)
}
else b[hc](b[Ec])
}
};
Q.getClassForState=function(a){
switch(a){
case 2:return this.getCompositeCssClass_(0);
case 16:case 8:return"goog-option-selected";
default:return Wn.superClass_.getClassForState[J](this,a)
}
};
Q.getStateFromClass=function(a){
var b=this.getCompositeCssClass_(0);
switch(a){
case "goog-option-selected":return 16;
case b:return 2;
default:return Wn.superClass_.getStateFromClass[J](this,a)
}
};
Q.getCssClass=function(){
return"goog-menuitem"
};
var Xn=function(a,b,c,e){
In[J](this,a,e||Wn.getInstance(),c);
this.setValue(b)
};
U(Xn,In);
Xn[y].getValue=function(){
var a=this.getModel();
return a!=j?a:this.getCaption()
};
Xn[y].setValue=function(a){
this.setModel(a)
};
Xn[y].setCheckable=function(a){
this.setSupportedState(16,a);
var b=this.getElement();
b&&this.getRenderer().setCheckable(this,b,a)
};
Xn[y].getCaption=function(){
return this.getCaptionInternal(function(a){
return Qe(ti(a),"goog-menuitem-accel")?"":aj(a)
}
)
};
En("goog-menuitem",function(){
return new Xn(j)
}
);
var Yn=function(){
};
U(Yn,Sn);
Kd(Yn);
Q=Yn[y];
Q.getAriaRole=function(){
return"menu"
};
Q.canDecorate=function(a){
return a[dd]=="UL"||Yn.superClass_.canDecorate[J](this,a)
};
Q.getDecoratorForChild=function(a){
return a[dd]=="HR"?new Rn:Yn.superClass_.getDecoratorForChild[J](this,a)
};
Q.containsElement=function(a,b){
return Ui(a.getElement(),b)
};
Q.getCssClass=function(){
return"goog-menu"
};
Q.initializeDom=function(a){
Yn.superClass_.initializeDom[J](this,a);
a=a.getElement();
ej(a,"haspopup","true")
};
var Zn=function(a){
Rn[J](this,Qn.getInstance(),a)
};
U(Zn,Rn);
En("goog-menuseparator",function(){
return new Rn
}
);
var $n=function(a,b){
Tn[J](this,"vertical",b||Yn.getInstance(),a);
this.setFocusable(k)
};
U($n,Tn);
Q=$n[y];
Q.allowAutoFocus_=i;
Q.allowHighlightDisabled_=k;
Q.getCssClass=function(){
return this.getRenderer().getCssClass()
};
Q.containsElement=function(a){
if(this.getRenderer().containsElement(this,a))return i;
for(var b=0,c=this.getChildCount();
b<c;
b++){
var e=this.getChildAt(b);
if(typeof e.containsElement=="function"&&e.containsElement(a))return i
}
return k
};
Q.addItem=function(a){
this.addChild(a,i)
};
Q.removeItemAt=function(a){
(a=this.removeChildAt(a,i))&&a.dispose()
};
Q.getItemAt=function(a){
return this.getChildAt(a)
};
Q.getItemCount=function(){
return this.getChildCount()
};
Q.setPosition=function(a,b){
var c=this.isVisible();
c||Qj(this.getElement(),i);
Kj(this.getElement(),a,b);
c||Qj(this.getElement(),k)
};
Q.setAllowAutoFocus=function(a){
(this.allowAutoFocus_=a)&&this.setFocusable(i)
};
Q.setVisible=function(a,b){
var c=$n.superClass_.setVisible[J](this,a,b);
c&&a&&this.isInDocument()&&this.allowAutoFocus_&&this.getKeyEventTarget()[zc]();
return c
};
Q.handleEnterItem=function(a){
this.allowAutoFocus_&&this.getKeyEventTarget()[zc]();
return $n.superClass_.handleEnterItem[J](this,a)
};
Q.canHighlightItem=function(a){
return(this.allowHighlightDisabled_||a.isEnabled())&&a.isVisible()&&a.isSupportedState(2)
};
Q.decorateInternal=function(a){
this.decorateContent(a);
$n.superClass_.decorateInternal[J](this,a)
};
Q.decorateContent=function(a){
var b=this.getRenderer();
a=this.getDomHelper().getElementsByTagNameAndClass("div",b.getCssClass()+"-content",a);
for(var c,e=0;
c=a[e];
e++)b.decorateChildren(this,c)
};
var ao=function(){
};
U(ao,Cn);
Kd(ao);
Q=ao[y];
Q.createDom=function(a){
var b=this.getClassNames(a);
b={
"class":"goog-inline-block "+b[ud](" "),title:a.getTooltip()||""
};
return a.getDomHelper().createDom("div",b,this.createButton(a.getContent(),a.getDomHelper()))
};
Q.getAriaRole=function(){
return"button"
};
Q.getContentElement=function(a){
return a&&a[Ec][Ec]
};
Q.createButton=function(a,b){
return b.createDom("div","goog-inline-block "+(this.getCssClass()+"-outer-box"),b.createDom("div","goog-inline-block "+(this.getCssClass()+"-inner-box"),a))
};
Q.canDecorate=function(a){
return a[dd]=="DIV"
};
Q.hasBoxStructure=function(a,b){
var c=a.getDomHelper().getFirstElementChild(b);
if(c&&c[ob][E](this.getCssClass()+"-outer-box")!=-1)if((c=a.getDomHelper().getFirstElementChild(c))&&c[ob][E](this.getCssClass()+"-inner-box")!=-1)return i;
return k
};
Q.decorate=function(a,b){
bo(b,i);
bo(b,k);
this.hasBoxStructure(a,b)||b[v](this.createButton(b[bd],a.getDomHelper()));
ui(b,"goog-inline-block",this.getCssClass());
return ao.superClass_.decorate[J](this,a,b)
};
Q.getCssClass=function(){
return"goog-custom-button"
};
var bo=function(a,b){
if(a)for(var c=b?a[Ec]:a[lc],e;
c&&c[O]==a;
){
e=b?c[md]:c.previousSibling;
if(c[zb]==3){
var f=c[yd];
if(je(f)=="")a[hc](c);
else{
c.nodeValue=b?f[B](/^[\s\xa0]+/,""):f[B](/[\s\xa0]+$/,"");
break
}
}
else break;
c=e
}
};
var co=function(){
};
U(co,ao);
Kd(co);
if(mg)co[y].setContent=function(a,b){
var c=co.superClass_.getContentElement[J](this,a&&a[Ec]);
c&&Si(this.createCaption(b,yi(a)),c)
};
Q=co[y];
Q.getContentElement=function(a){
a=co.superClass_.getContentElement[J](this,a&&a[Ec]);
if(mg&&a&&a.__goog_wrapper_div)a=a[Ec];
return a
};
Q.decorate=function(a,b){
var c=Bi("*","goog-menu",b)[0];
if(c){
Qj(c,k);
xi(c)[dc][v](c);
var e=new $n;
e.decorate(c);
a.setMenu(e)
}
return co.superClass_.decorate[J](this,a,b)
};
Q.createButton=function(a,b){
return co.superClass_.createButton[J](this,[this.createCaption(a,b),this.createDropdown(b)],b)
};
Q.createCaption=function(a,b){
return b.createDom("div","goog-inline-block "+(this.getCssClass()+"-caption"),a)
};
Q.createDropdown=function(a){
return a.createDom("div","goog-inline-block "+(this.getCssClass()+"-dropdown"),"\u00a0")
};
Q.getCssClass=function(){
return"goog-menu-button"
};
var eo=function(a,b,c,e){
Pn[J](this,a,c||co.getInstance(),e);
this.setSupportedState(64,i);
b&&this.setMenu(b);
this.timer_=new Bh(500)
};
U(eo,Pn);
Q=eo[y];
Q.alignToStart_=i;
Q.scrollOnOverflow_=k;
Q.isFocusablePopupMenu_=k;
Q.enterDocument=function(){
eo.superClass_.enterDocument[J](this);
this.menu_&&this.attachMenuEventListeners_(this.menu_,i);
ej(this.getElement(),"haspopup","true")
};
Q.exitDocument=function(){
eo.superClass_.exitDocument[J](this);
if(this.menu_){
this.setOpen(k);
this.menu_.exitDocument();
this.attachMenuEventListeners_(this.menu_,k);
var a=this.menu_.getElement();
a&&Ri(a)
}
};
Q.disposeInternal=function(){
eo.superClass_.disposeInternal[J](this);
if(this.menu_){
this.menu_.dispose();
delete this.menu_
}
delete this.positionElement_;
this.timer_.dispose()
};
Q.handleMouseDown=function(a){
eo.superClass_.handleMouseDown[J](this,a);
if(this.isActive()){
this.setOpen(!this[qc]());
this.menu_&&this.menu_.setMouseButtonPressed(this[qc]())
}
};
Q.handleMouseUp=function(a){
eo.superClass_.handleMouseUp[J](this,a);
this.menu_&&!this.isActive()&&this.menu_.setMouseButtonPressed(k)
};
Q.performActionInternal=function(){
this[wd](k);
return i
};
Q.handleDocumentMouseDown=function(a){
this.menu_&&this.menu_.isVisible()&&!this.containsElement(a[I])&&this.setOpen(k)
};
Q.containsElement=function(a){
return a&&Ui(this.getElement(),a)||this.menu_&&this.menu_.containsElement(a)||k
};
Q.handleKeyEventInternal=function(a){
if(a[Dc]==32){
a[Sb]();
if(a[Zc]!="keyup")return k
}
else if(a[Zc]!="key")return k;
if(this.menu_&&this.menu_.isVisible()){
var b=this.menu_.handleKeyEvent(a);
if(a[Dc]==27){
this.setOpen(k);
return i
}
return b
}
if(a[Dc]==40||a[Dc]==38||a[Dc]==32){
this.setOpen(i);
return i
}
return k
};
Q.handleMenuAction=function(){
this.setOpen(k)
};
Q.handleMenuBlur=function(){
this.isActive()||this.setOpen(k)
};
Q.handleBlur=function(a){
this.isFocusablePopupMenu()||this.setOpen(k);
eo.superClass_.handleBlur[J](this,a)
};
Q.getMenu=function(){
this.menu_||this.setMenu(new $n(this.getDomHelper()));
return this.menu_||j
};
Q.setMenu=function(a){
var b=this.menu_;
if(a!=b){
if(b){
this.setOpen(k);
this.isInDocument()&&this.attachMenuEventListeners_(b,k);
delete this.menu_
}
if(a){
this.menu_=a;
a.setParent(this);
a.setVisible(k);
a.setAllowAutoFocus(this.isFocusablePopupMenu());
this.isInDocument()&&this.attachMenuEventListeners_(a,i)
}
}
return b
};
Q.addItem=function(a){
this.getMenu().addChild(a,i)
};
Q.removeItemAt=function(a){
(a=this.getMenu().removeChildAt(a,i))&&a.dispose()
};
Q.getItemAt=function(a){
return this.menu_?this.menu_.getChildAt(a):j
};
Q.getItemCount=function(){
return this.menu_?this.menu_.getChildCount():0
};
Q.setVisible=function(a,b){
var c=eo.superClass_.setVisible[J](this,a,b);
c&&!this.isVisible()&&this.setOpen(k);
return c
};
Q.setEnabled=function(a){
eo.superClass_.setEnabled[J](this,a);
this.isEnabled()||this.setOpen(k)
};
Q.isAlignMenuToStart=function(){
return this.alignToStart_
};
Q.setScrollOnOverflow=function(a){
this.scrollOnOverflow_=a
};
Q.isFocusablePopupMenu=function(){
return this.isFocusablePopupMenu_
};
Q.showMenu=function(){
this.setOpen(i)
};
Q.setOpen=function(a){
eo.superClass_.setOpen[J](this,a);
if(this.menu_&&this.hasState(64)==a){
if(a){
this.menu_.isInDocument()||this.menu_.render();
this.viewportBox_=Jj(this.getElement());
this.buttonRect_=Nj(this.getElement());
this.positionMenu();
this.menu_.setHighlightedIndex(-1)
}
else{
this[wd](k);
this.menu_.setMouseButtonPressed(k);
if(this.originalSize_!=j){
this.originalSize_=ba;
var b=this.menu_.getElement();
b&&Lj(b,"","")
}
}
this.menu_.setVisible(a);
this.attachPopupListeners_(a)
}
};
Q.positionMenu=function(){
if(this.menu_.isInDocument()){
var a=this.positionElement_||this.getElement(),b=this.isAlignMenuToStart()?5:7;
a=new zn(a,b,!this.scrollOnOverflow_,this.scrollOnOverflow_);
b=this.menu_.getElement();
if(!this.menu_.isVisible()){
$a(b[H],"hidden");
Qj(b,i)
}
if(!this.originalSize_&&this.scrollOnOverflow_)this.originalSize_=Mj(b);
var c=this.isAlignMenuToStart()?4:6;
a.reposition(b,c,j,this.originalSize_);
if(!this.menu_.isVisible()){
Qj(b,k);
$a(b[H],"visible")
}
}
};
Q.onTick_=function(){
var a=Nj(this.getElement()),b=Jj(this.getElement()),c;
c=this.buttonRect_;
c=c==a?i:!c||!a?k:c[ec]==a[ec]&&c[z]==a[z]&&c.top==a.top&&c[P]==a[P];
if(!(c=!c)){
c=this.viewportBox_;
c=c==b?i:!c||!b?k:c.top==b.top&&c[Fd]==b[Fd]&&c[Nc]==b[Nc]&&c[ec]==b[ec];
c=!c
}
if(c){
this.buttonRect_=a;
this.viewportBox_=b;
this.positionMenu()
}
};
Q.attachMenuEventListeners_=function(a,b){
var c=this.getHandler(),e=b?c.listen:c.unlisten;
e[J](c,a,"action",this.handleMenuAction);
e[J](c,a,"highlight",this.handleHighlightItem);
e[J](c,a,"unhighlight",this.handleUnHighlightItem)
};
Q.handleHighlightItem=function(a){
ej(this.getElement(),"activedescendant",a[I].getElement().id)
};
Q.handleUnHighlightItem=function(){
this.menu_.getHighlighted()||ej(this.getElement(),"activedescendant","")
};
Q.attachPopupListeners_=function(a){
var b=this.getHandler(),c=a?b.listen:b.unlisten;
c[J](b,this.getDomHelper().getDocument(),"mousedown",this.handleDocumentMouseDown,i);
this.isFocusablePopupMenu()&&c[J](b,this.menu_,"blur",this.handleMenuBlur);
c[J](b,this.timer_,"tick",this.onTick_);
a?this.timer_[xc]():this.timer_[cb]()
};
En("goog-menu-button",function(){
return new eo(j)
}
);
var fo=/^onEvent\.(\w+)$/i,ho=function(a){
if(Od(a))a=Z(a);
if(!a)return j;
for(var b={
}
,c=[],e=0;
e<a[hd][x];
e++){
var f=a[hd][e],g=fo[rb](f[bc]);
if(g)(g=Ek[g[1][qd]()])&&c[w]([g,f[yd]]);
else b[f[bc]]=f[yd]
}
var h=Jn(a);
e=i;
if(f=b.enabled){
var n=new jl(f);
f=n.getDataDeps();
for(e=0;
e<f[x];
e++)V().addListener(function(){
h.setEnabled(n.getValue())
}
,f[e].getSource());
e=n.getValue()
}
h.setEnabled(e);
var o=b.gaction;
o&&Y(h,"action",function(){
a[Mb]();
(new Function(o))[J](a)
}
);
for(e=0;
e<c[x];
++e)go(h,c[e][0],
c[e][1])
}
,go=function(a,b,c){
b=="open"&&a.setDispatchTransitionEvents(64,i);
var e=new Function(c);
Y(a,b,function(){
e[J](a)
}
)
};
var io=function(a,b){
switch(b){
case 1:return a%4==0&&(a%100!=0||a%400==0)?29:28;
case 5:case 8:case 10:case 3:return 30
}
return 31
}
,jo=function(a,b,c){
if(Pd(a)){
this.date_=new Date(a,b||0,c||1);
this.maybeFixDst_(c||1)
}
else if(Rd(a)){
this.date_=new Date(a[Fc](),a[eb](),a[Qb]());
this.maybeFixDst_(a[Qb]())
}
else{
this.date_=new Date;
this.date_.setHours(0);
this.date_.setMinutes(0);
this.date_.setSeconds(0);
this.date_.setMilliseconds(0)
}
};
Q=jo[y];
Q.firstDayOfWeek_=0;
Q.firstWeekCutOffDay_=3;
Q.clone=function(){
var a=new jo(this.date_);
a.firstDayOfWeek_=this.firstDayOfWeek_;
a.firstWeekCutOffDay_=this.firstWeekCutOffDay_;
return a
};
Q.getFullYear=function(){
return this.date_[Fc]()
};
Q.getYear=function(){
return this[Fc]()
};
Q.getMonth=function(){
return this.date_[eb]()
};
Q.getDate=function(){
return this.date_[Qb]()
};
Q.getTime=function(){
return this.date_[sd]()
};
Q.getDay=function(){
return this.date_.getDay()
};
Q.getUTCFullYear=function(){
return this.date_.getUTCFullYear()
};
Q.getUTCMonth=function(){
return this.date_.getUTCMonth()
};
Q.getUTCDate=function(){
return this.date_.getUTCDate()
};
Q.getUTCDay=function(){
return this.date_.getDay()
};
Q.getUTCHours=function(){
return this.date_.getUTCHours()
};
Q.getUTCMinutes=function(){
return this.date_.getUTCMinutes()
};
Q.getFirstDayOfWeek=function(){
return this.firstDayOfWeek_
};
Q.getFirstWeekCutOffDay=function(){
return this.firstWeekCutOffDay_
};
Q.getNumberOfDaysInMonth=function(){
return io(this[Fc](),this[eb]())
};
Q.getTimezoneOffset=function(){
return this.date_.getTimezoneOffset()
};
Q.getTimezoneOffsetString=function(){
var a;
a=this.getTimezoneOffset();
if(a==0)a="Z";
else{
var b=r.abs(a)/60,c=r[Gb](b);
b=(b-c)*60;
a=(a>0?"-":"+")+Ae(c,2)+":"+Ae(b,2)
}
return a
};
Q.set=function(a){
this.date_=new Date(a[Fc](),a[eb](),a[Qb]())
};
Q.setFullYear=function(a){
this.date_.setFullYear(a)
};
Q.setMonth=function(a){
this.date_.setMonth(a)
};
Q.setDate=function(a){
this.date_[ab](a)
};
Q.setTime=function(a){
this.date_.setTime(a)
};
Q.setUTCFullYear=function(a){
this.date_.setUTCFullYear(a)
};
Q.setUTCMonth=function(a){
this.date_.setUTCMonth(a)
};
Q.setUTCDate=function(a){
this.date_.setUTCDate(a)
};
Q.setFirstDayOfWeek=function(a){
this.firstDayOfWeek_=a
};
Q.setFirstWeekCutOffDay=function(a){
this.firstWeekCutOffDay_=a
};
Q.add=function(a){
if(a.years||a.months){
var b=this[eb]()+a.months+a.years*12,c=this.getYear()+r[Gb](b/12);
b%=12;
if(b<0)b+=12;
var e=io(c,b);
e=r.min(e,this[Qb]());
this[ab](1);
this.setFullYear(c);
this.setMonth(b);
this[ab](e)
}
if(a.days){
b=new Date(this.getYear(),this[eb](),this[Qb](),12);
a=new Date(b[sd]()+a.days*864E5);
this[ab](1);
this.setFullYear(a[Fc]());
this.setMonth(a[eb]());
this[ab](a[Qb]());
this.maybeFixDst_(a[Qb]())
}
};
Q.toIsoString=function(a,b){
var c=[this[Fc](),Ae(this[eb]()+1,2),Ae(this[Qb](),2)];
return c[ud](a?"-":"")+(b?this.getTimezoneOffsetString():"")
};
na(Q,function(){
return this.toIsoString()
}
);
Q.maybeFixDst_=function(a){
if(this[Qb]()!=a){
a=this[Qb]()<a?1:-1;
this.date_.setUTCHours(this.date_.getUTCHours()+a)
}
};
Q.valueOf=function(){
return this.date_.valueOf()
};
var ko=function(a,b,c,e,f,g,h){
this.date_=Pd(a)?new Date(a,b||0,c||1,e||0,f||0,g||0,h||0):new Date(a?a[sd]():$d())
};
U(ko,jo);
Q=ko[y];
Q.getHours=function(){
return this.date_[id]()
};
Q.getMinutes=function(){
return this.date_[jd]()
};
Q.getSeconds=function(){
return this.date_[Cb]()
};
Q.getMilliseconds=function(){
return this.date_.getMilliseconds()
};
Q.getUTCDay=function(){
return this.date_.getUTCDay()
};
Q.getUTCHours=function(){
return this.date_.getUTCHours()
};
Q.getUTCMinutes=function(){
return this.date_.getUTCMinutes()
};
Q.getUTCSeconds=function(){
return this.date_.getUTCSeconds()
};
Q.getUTCMilliseconds=function(){
return this.date_.getUTCMilliseconds()
};
Q.setHours=function(a){
this.date_.setHours(a)
};
Q.setMinutes=function(a){
this.date_.setMinutes(a)
};
Q.setSeconds=function(a){
this.date_.setSeconds(a)
};
Q.setMilliseconds=function(a){
this.date_.setMilliseconds(a)
};
Q.setUTCHours=function(a){
this.date_.setUTCHours(a)
};
Q.setUTCMinutes=function(a){
this.date_.setUTCMinutes(a)
};
Q.setUTCSeconds=function(a){
this.date_.setUTCSeconds(a)
};
Q.setUTCMilliseconds=function(a){
this.date_.setUTCMilliseconds(a)
};
Q.add=function(a){
jo[y].add[J](this,a);
a.hours&&this.setHours(this.date_[id]()+a.hours);
a.minutes&&this.setMinutes(this.date_[jd]()+a.minutes);
a.seconds&&this.setSeconds(this.date_[Cb]()+a.seconds)
};
Q.toIsoString=function(a,b){
var c=jo[y].toIsoString[J](this,a);
if(a)return c+" "+Ae(this[id](),2)+":"+Ae(this[jd](),2)+":"+Ae(this[Cb](),2)+(b?this.getTimezoneOffsetString():"");
return c+"T"+Ae(this[id](),2)+Ae(this[jd](),2)+Ae(this[Cb](),2)+(b?this.getTimezoneOffsetString():"")
};
na(Q,function(){
return this.toIsoString()
}
);
Q.clone=function(){
var a=new ko(this.date_);
a.setFirstDayOfWeek(this.getFirstDayOfWeek());
a.setFirstWeekCutOffDay(this.getFirstWeekCutOffDay());
return a
};
var lo=function(a,b,c,e,f){
function g(n){
if(n){
n.tabIndex=0;
Y(n,"click",h.onHeaderClick_,k,h);
Y(n,"keydown",h.onHeaderKeyDown_,k,h)
}
}
this.dom_=f||yi();
this.elHeader_=this.dom_.getElement(a)||j;
this.elExpandedHeader_=this.dom_.getElement(e||j);
this.elContent_=(this.lazyCreateFunc_=Qd(b)?b:j)||!b?j:this.dom_.getElement(b);
this.expanded_=c==i;
var h=this;
g(this.elHeader_);
g(this.elExpandedHeader_);
this.setExpanded(this.expanded_)
};
U(lo,uh);
Q=lo[y];
Q.disposeInternal=function(){
this.elHeader_&&ph(this.elHeader_);
this.elExpandedHeader_&&ph(this.elExpandedHeader_);
lo.superClass_.disposeInternal[J](this)
};
Q.expand=function(){
this.setExpanded(i)
};
Q.collapse=function(){
this.setExpanded(k)
};
Q.toggle=function(){
this.setExpanded(!this.expanded_)
};
Q.setExpanded=function(a){
if(this.elContent_)Qj(this.elContent_,a);
else if(a&&this.lazyCreateFunc_)this.elContent_=this.lazyCreateFunc_();
if(this.elExpandedHeader_){
Qj(this.elHeader_,!a);
Qj(this.elExpandedHeader_,a)
}
else this.updateHeaderClassName_(a);
this.expanded_=a;
this[F](new mo("toggle",this,this.expanded_))
};
Q.updateHeaderClassName_=function(a){
if(this.elHeader_){
var b=this.elHeader_,c="goog-zippy-expanded";
a?ui(b,c):vi(b,c);
b=this.elHeader_;
c="goog-zippy-collapsed";
!a?ui(b,c):vi(b,c)
}
};
Q.onHeaderKeyDown_=function(a){
if(a[Dc]==13||a[Dc]==32){
this.toggle();
a[Sb]();
a[Ob]()
}
};
Q.onHeaderClick_=function(){
this.toggle()
};
var mo=function(a,b,c){
Ig[J](this,a,b);
this.expanded=c
};
U(mo,Ig);
var no=function(a,b,c){
b||(b={
}
);
var e=c||p;
c=typeof a[Rc]!="undefined"?a[Rc]:m(a);
a=b[I]||a[I];
var f=[],g;
for(g in b)switch(g){
case "width":case "height":case "top":case "left":f[w](g+"="+b[g]);
break;
case "target":case "noreferrer":break;
default:f[w](g+"="+(b[g]?1:0))
}
g=f[ud](",");
if(b.noreferrer){
if(b=e[kb]("",a,g)){
b[Ab].write('<META HTTP-EQUIV="refresh" content="0;
url='+se(c)+'">');
b[Ab][ac]()
}
}
else b=e[kb](c,a,g);
return b
};
var oo=function(a,b){
this.coordinate=a instanceof ki?a:new ki(a,b)
};
U(oo,wn);
oo[y].reposition=function(a,b,c,e){
var f=Ej(a),g=new ki(this.coordinate.x+f[Ic],this.coordinate.y+f[bb]);
vn(f,0,a,b,g,c,j,e)
};
var po=function(a,b){
oo[J](this,a,b)
};
U(po,oo);
po[y].reposition=function(a,b,c,e){
var f=Ej(a);
f=Jj(f);
var g=yi(a).getDocumentScrollElement();
g=new ki(this.coordinate.x+g[Ic],this.coordinate.y+g[bb]);
var h=10,n=b,o=un(g,a,n,c,f,h,e);
if((o&496)!=0){
if(o&16||o&32)n^=2;
if(o&64||o&128)n^=1;
o=un(g,a,n,c,f,h,e);
(o&496)!=0&&un(g,a,b,c,f,ba,e)
}
};
var qo=function(a,b){
this.handler_=new jj(this);
this.setElement(a||j);
b&&this.setType(b)
};
U(qo,uh);
Q=qo[y];
Q.element_=j;
Q.autoHide_=i;
Q.autoHideRegion_=j;
Q.isVisible_=k;
Q.shouldHideAsync_=k;
Q.lastShowTime_=-1;
Q.lastHideTime_=-1;
Q.hideOnEscape_=k;
Q.enableCrossIframeDismissal_=i;
Q.type_="toggle_display";
Q.getType=function(){
return this.type_
};
Q.setType=function(a){
this.type_=a
};
Q.getElement=function(){
return this.element_
};
Q.setElement=function(a){
this.ensureNotVisible_();
this.element_=a
};
Q.ensureNotVisible_=function(){
if(this.isVisible_)d(l("Can not change this state of the popup while showing."))
};
Q.isVisible=function(){
return this.isVisible_
};
Q.setVisible=function(a){
a?this.show_():this.hide_()
};
Q.reposition=Jd;
Q.show_=function(){
if(!this.isVisible_)if(this.onBeforeShow()){
if(!this.element_)d(l("Caller must call setElement before trying to show the popup"));
this.reposition();
var a=xi(this.element_);
this.hideOnEscape_&&this.handler_.listen(a,"keydown",this.onDocumentKeyDown_,i);
if(this.autoHide_){
this.handler_.listen(a,"mousedown",this.onDocumentMouseDown_,i);
if(X){
for(var b=a[gb];
b&&b[bc]=="IFRAME";
){
try{
var c=Vi(b)
}
catch(e){
break
}
a=c;
b=a[gb]
}
this.handler_.listen(a,"mousedown",this.onDocumentMouseDown_,
i);
this.handler_.listen(a,"deactivate",this.onDocumentBlur_)
}
else this.handler_.listen(a,"blur",this.onDocumentBlur_)
}
if(this.type_=="toggle_display")this.showPopupElement();
else this.type_=="move_offscreen"&&this.reposition();
this.isVisible_=i;
this.onShow_()
}
};
Q.hide_=function(a){
if(!this.isVisible_||!this.onBeforeHide_(a))return k;
this.handler_&&this.handler_.removeAll();
if(this.type_=="toggle_display")this.shouldHideAsync_?Dh(this.hidePopupElement_,0,this):this.hidePopupElement_();
else this.type_=="move_offscreen"&&this.moveOffscreen_();
this.isVisible_=k;
this.onHide_(a);
return i
};
Q.showPopupElement=function(){
$a(this.element_[H],"visible");
Qj(this.element_,i)
};
Q.hidePopupElement_=function(){
$a(this.element_[H],"hidden");
Qj(this.element_,k)
};
Q.moveOffscreen_=function(){
Da(this.element_[H],"-200px");
this.element_[H].top="-200px"
};
Q.onBeforeShow=function(){
return this[F]("beforeshow")
};
Q.onShow_=function(){
this.lastShowTime_=$d();
this.lastHideTime_=-1;
this[F]("show")
};
Q.onBeforeHide_=function(a){
return this[F]({
type:"beforehide",target:a
}
)
};
Q.onHide_=function(a){
this.lastHideTime_=$d();
this[F]({
type:"hide",target:a
}
)
};
Q.onDocumentMouseDown_=function(a){
a=a[I];
if(!Ui(this.element_,a)&&(!this.autoHideRegion_||Ui(this.autoHideRegion_,a))&&!this.shouldDebounce_())this.hide_(a)
};
Q.onDocumentKeyDown_=function(a){
if(a[Dc]==27)if(this.hide_(a[I])){
a[Sb]();
a[Ob]()
}
};
Q.onDocumentBlur_=function(a){
if(this.enableCrossIframeDismissal_){
var b=xi(this.element_);
if(X||lg){
if((a=b[gb])&&Ui(this.element_,a))return
}
else if(a[I]!=b)return;
this.shouldDebounce_()||this.hide_()
}
};
Q.shouldDebounce_=function(){
return $d()-this.lastShowTime_<150
};
Q.disposeInternal=function(){
qo.superClass_.disposeInternal[J](this);
this.handler_.dispose();
delete this.element_;
delete this.handler_
};
var ro=function(a,b){
$n[J](this,a,b);
this.setAllowAutoFocus(i);
this.setVisible(k,i);
this.targets_=new qf
};
U(ro,$n);
Q=ro[y];
Q.toggleMode_=k;
Q.lastHide_=0;
Q.currentAnchor_=j;
Q.decorateInternal=function(a){
ro.superClass_.decorateInternal[J](this,a);
(a=a[Ac]("for")||a.htmlFor)&&this.attach(this.getDomHelper().getElement(a),1)
};
Q.enterDocument=function(){
ro.superClass_.enterDocument[J](this);
pf(this.targets_,this.attachEvent_,this);
var a=this.getHandler();
a.listen(this,"action",this.onAction_);
a.listen(this.getDomHelper().getDocument(),"mousedown",this.onDocClick,i);
ng&&a.listen(this.getDomHelper().getDocument(),"contextmenu",this.onDocClick,i)
};
Q.attach=function(a,b,c,e,f){
if(!this.isAttachTarget(a)){
a=this.createAttachTarget(a,b,c,e,f);
this.isInDocument()&&this.attachEvent_(a)
}
};
Q.createAttachTarget=function(a,b,c,e,f){
if(!a)return j;
b={
element_:a,targetCorner_:b,menuCorner_:c,eventType_:e?"contextmenu":"mousedown",margin_:f
};
this.targets_.set(Ud(a),b);
return b
};
Q.isAttachTarget=function(a){
return a?this.targets_.containsKey(Ud(a)):k
};
Q.attachEvent_=function(a){
this.getHandler().listen(a.element_,a.eventType_,this.onTargetClick_)
};
Q.detach=function(a){
if(!this.isAttachTarget(a))d(l("Menu not attached to provided element, unable to detach."));
a=Ud(a);
this.isInDocument()&&this.detachEvent_(this.targets_.get(a));
this.targets_[wc](a)
};
Q.detachEvent_=function(a){
this.getHandler().unlisten(a.element_,a.eventType_,this.onTargetClick_)
};
Q.setToggleMode=function(a){
this.toggleMode_=a
};
Q.showWithPosition=function(a,b,c,e){
var f=this.isVisible();
if((f||this.wasRecentlyHidden())&&this.toggleMode_)this.hide();
else{
this.currentAnchor_=e||j;
if(this[F]("beforeshow")){
b=typeof b!="undefined"?b:4;
if(!f)$a(this.getElement()[H],"hidden");
Qj(this.getElement(),i);
a.reposition(this.getElement(),b,c);
if(!f)$a(this.getElement()[H],"visible");
this.setHighlightedIndex(-1);
this.setVisible(i)
}
}
};
Q.showMenu=function(a,b,c){
b=a.targetCorner_!==ba?new yn(a.element_,a.targetCorner_,i):new po(b,c);
this.showWithPosition(b,a.menuCorner_,a.margin_,a.element_)
};
Q.hide=function(){
if(this.isVisible()){
this.setVisible(k);
if(!this.isVisible()){
this.lastHide_=$d();
this.currentAnchor_=j
}
}
};
Q.wasRecentlyHidden=function(){
return $d()-this.lastHide_<150
};
Q.onAction_=function(){
this.hide()
};
Q.onTargetClick_=function(a){
for(var b=this.targets_.getKeys(),c=0;
c<b[x];
c++){
var e=this.targets_.get(b[c]);
if(e.element_==a[cc]){
this.showMenu(e,a[Bd],a[Cd]);
a[Sb]();
a[Ob]();
break
}
}
};
Q.onDocClick=function(a){
this.isVisible()&&!this.containsElement(a[I])&&this.hide()
};
Q.handleBlur=function(a){
ro.superClass_.handleBlur[J](this,a);
this.hide()
};
Q.disposeInternal=function(){
ro.superClass_.disposeInternal[J](this);
if(this.targets_){
this.targets_[ad]();
delete this.targets_
}
};
var so=function(a){
ro[J](this);
this.decorate(a);
this.setToggleMode(i);
for(var b=V(),c=0,e=this.getItemCount();
c<e;
++c){
var f=this.getItemAt(c),g=f.getElement()[hd].getNamedItem("disableif");
if(g){
this.disableItemIf_(f,g[D]);
b.addListener(T(this.disableItemIf_,this,f,g[D]),g[D])
}
}
Y(this,"action",T(this.blur_,this,a))
};
U(so,ro);
so[y].disableItemIf_=function(a,b){
$[C](b)&&a.setEnabled(k)
};
so[y].blur_=function(a){
a[Mb]()
};
var to=function(){
this.map_=new qf;
this.pam_=new qf
};
Q=to[y];
Q.add=function(a,b){
this.addToMap_(this.map_,a,b);
this.addToMap_(this.pam_,b,a)
};
Q.addToMap_=function(a,b,c){
var e=a.get(b,[]);
if(!Qe(e,c)){
e[w](c);
a.set(b,e)
}
};
Q.get=function(a){
return this.map_.get(a,j)
};
Q.removeValue=function(a){
var b=this.pam_.get(a);
if(b){
for(var c=0;
c<b[x];
c++){
var e=b[c],f=this.map_.get(e);
if(f){
Se(f,a);
f[x]==0&&this.map_[wc](e)
}
}
this.pam_[wc](a)
}
};
Q.getKeys=function(){
return this.map_.getKeys()
};
Q.getValues=function(){
return this.pam_.getKeys()
};
Ra(Q,function(){
this.map_[ad]();
this.pam_[ad]()
}
);
var vo=function(a,b,c){
var e=a.Id;
c=c||e;
a.id=e;
if(a.Groups==j)a.Groups=[];
if((e=$[C]("$UserData/IsGcUser"))&&!a.CallSettings)a.CallSettings={
GreetingId:"0",RingshareId:"0",GroupId:"0",Mode:"GROUP",Response:"DEFAULT",AlwaysScreen:"false",DirectConnect:k
};
if(a.Organizations){
e=a.Organizations[x]>0?a.Organizations[0]:j;
if(e!=j){
a.FirstOrganization=e;
e=a;
var f;
f=a.Organizations;
for(var g=[],h=1;
h<f[x];
h++)g[w](f[h]);
f=g;
e.OtherOrganizations=f
}
}
a.InterleavedProfileData={
};
a.InterleavedProfileLabels=[];
a.InterleavedProfileIds={
};
a.UnderleavedProfiles=[];
a.UnderleavedProfileIds={
};
e=a.Links;
if(!(!e||e[x]==0))for(f=0;
f<e[x];
f++){
b:{
g=e[f].Url;
if(ve(g,":")){
for(h=0;
h<uo[x];
h++)if(be(g[zd](),uo[h]+":")){
g=i;
break b
}
g=k
}
else g=i
}
if(g)e[f].Supported=i
}
e=a;
if(e.ProfileLink&&e.ProfileLink!=""){
f=new Sh(e.ProfileLink);
g=V();
g=g.getChildNodeValue("$Locale");
f.setParameterValue("hl",g);
e.ProfileLink=f
}
ei[J](this,a,c,b)
};
U(vo,ei);
var uo=["http","https","ftp","mailto"],wo=["Name","Title","Company","Notes"],xo=["FirstOrganization"],yo=["Birthday/Day","Birthday/Month","Birthday/Year"],zo={
Emails:{
Primary:["Address"],Other:["Type/Id","Type/Label","Primary"]
}
,Others:{
Primary:["Value"],Other:["Type/Id","Type/Label"]
}
,Phones:{
Primary:["Number"],Other:["Type/Id","Type/Label"]
}
,Ims:{
Primary:["Name"],Other:["Service/Id","Service/Label","Type/Id","Type/Label"]
}
,Addresses:{
Primary:["Street","City","Region","Postal","Unstructured"],Other:["Type/Id",
"Type/Label","Source"]
}
,NickNames:{
Primary:["Value"],Other:["Type/Id"]
}
,Relations:{
Primary:["Name"],Other:["Type/Id","Type/Label"]
}
,CustomFields:{
Primary:["Key","Value"],Other:["IsSmartCustom"]
}
,Links:{
Primary:["Url"],Other:["Type/Id"]
}
,Dates:{
Primary:[],Other:["Day","Month","Year","Type/Id","Type/Label"]
}
}
,Ao={
}
,Bo=["ExternalIds"],Co;
for(Co in zo){
var Do=zo[Co];
Ao[Co]=Do.Primary[Kb](Do.Other)
}
Q=vo[y];
Q.getChildNodeValue=function(a){
if(a=="UnlockedGroupsCount")return this.getUnlockedGroups().getChildNodes().getCount();
if(a=="GcSettingsType")return this.getGcSettingsType();
if(a=="DefaultNickName")return this.getDefaultNickName_();
this.initializePictureIfNeeded_(a);
return vo.superClass_.getChildNodeValue[J](this,a)
};
Q.getChildNode=function(a,b){
if(a=="UnlockedGroups")return this.getUnlockedGroups();
if(a=="AutoGroup")return this.getAutoGroup();
if(a=="AutoGreeting")return this.getAutoGreeting();
this.initializePictureIfNeeded_(a);
return vo.superClass_.getChildNode[J](this,a,b)
};
Q.setChildNode=function(a,b){
if(a=="DefaultNickName")return this.setDefaultNickName_(b);
return vo.superClass_.setChildNode[J](this,a,b)
};
Q.getUnlockedGroups=function(){
for(var a=new wk({
}
,"UnlockedGroups",this),b=this.getChildNode("Groups",i).getChildNodes(),c=0;
c<b.getCount();
c++){
var e=b.getByIndex(c),f=e.getChildNodeValue("id"),g=e.getChildNode("ref");
g&&!g.getChildNodeValue("IsLocked")&&a.getChildNodes().add(Vf(e,f))
}
return a
};
Q.getAutoGroup=function(){
for(var a={
"^Friends":1,"^Family":2,"^Work":3,"^Following":4
}
,b=0,c="0",e=ba,f=this.getUnlockedGroups().getChildNodes(),g=f.getCount(),h=0;
h<g;
h++){
var n=f.getByIndex(h),o=n.getChildNodeValue("id"),s=a[o]||da(o,16);
if(b==0){
b=s;
c=o;
e=n
}
else if(s<b){
b=s;
c=o;
e=n
}
}
return c!="0"?Vf(e,c):j
};
Q.getAutoGreeting=function(){
for(var a=W("$UserProfile/GcProfile/Greetings/*").getNodes(),b=this.getChildNode("CallSettings").getChildNodeValue("GreetingId"),c=0;
c<a.getCount();
c++){
var e=a.getByIndex(c),f=e.getChildNodeValue("Id");
if(b==f)return e
}
a={
Id:"0",Name:"Default Greeting"
};
return hi(a,"$DummyGreeting")
};
Q.getGcSettingsType=function(){
var a=this.getChildNode("CallSettings");
if(a&&a.getChildNodeValue("Mode")=="CUSTOM")return"CUSTOM";
var b=this.getUnlockedGroups().getChildNodes().getCount();
if(b==0)return"NO_GROUP";
if(!a)return"AUTO_GROUP";
for(var c=0;
c<b;
c++){
var e=this.getUnlockedGroups().getChildNodes().getByIndex(c).getChildNodeValue("id");
if(e==a.getChildNodeValue("GroupId"))return"GROUP"
}
return"AUTO_GROUP"
};
Q.getDefaultNickName_=function(){
for(var a=$.getNodes("NickNames/*",this),b=a.getCount(),c=0;
c<b;
++c){
var e=a.getByIndex(c);
if($[C]("Type/Id",e)=="DEFAULT")return e.getChildNodeValue("Value")
}
return j
};
Q.setDefaultNickName_=function(a){
for(var b=$.getNodes("NickNames/*",this),c=b.getCount(),e=0;
e<c;
++e){
var f=b.getByIndex(e);
if($[C]("Type/Id",f)=="DEFAULT"){
f.setChildNode("Value",a);
break
}
}
};
Q.initializePictureIfNeeded_=function(a){
if((a=="ForcedPicture"||a=="MaybeHasPicture")&&!this.__PictureInitialized){
this.__PictureInitialized=i;
this.refreshPicture()
}
};
Q.refreshPicture=function(){
var a=this.getPictureUrl();
if(a){
this.setChildNode("ForcedPicture",a);
this.setChildNode("MaybeHasPicture",i)
}
else this.setChildNode("MaybeHasPicture",k)
};
Q.setHasNoPicture=function(){
this.setChildNode("MaybeHasPicture",k)
};
Q.setIsProfileLoaded=function(a){
this.setChildNode("ProfileLoaded",a)
};
Q.isProfileLoaded=function(){
return this.getChildNodeValue("ProfileLoaded")||k
};
Q.setIsInterleavedProfileDataLoaded=function(a){
this.setChildNode("InterleavedProfileDataLoaded",a)
};
Q.isInterleavedProfileDataLoaded=function(){
return this.getChildNodeValue("InterleavedProfileDataLoaded")||k
};
Q.setAreUnderleavedProfilesLoaded=function(a){
this.setChildNode("UnderleavedProfilesLoaded",a)
};
Q.areUnderleavedProfilesLoaded=function(){
return this.getChildNodeValue("UnderleavedProfilesLoaded")||k
};
Q.setNeverSuggest=function(a){
this.setChildNode("NeverSuggest",a)
};
Q.isNeverSuggest=function(){
return this.getChildNode("NeverSuggest")||k
};
Q.getPictureUrl=function(a){
var b=Lm().getFfeServerPath(),c=j;
if(a)c=(a=this.getChildNodeValue("EvergreenPhoto"))?b+a:j;
else c=(a=this.getChildNodeValue("Photo"))?b+a:$[C]("$Images/NoPicture");
return c
};
na(Q,function(a){
return this.getEmail()?this.getAsEmailString(i,k,a):this.getDisplayName()
}
);
Q.getName=function(){
return this.getChildNodeValue("Name")
};
Q.getDefaultNickName=function(){
var a=this.getChildNode("NickNames");
if(a)if((a=a.getChildNodes())&&a.getCount()>0)return a.getByIndex(0).getChildNodeValue("Value");
return j
};
Q.getDisplayName=function(){
return this.getChildNodeValue("DisplayName")
};
Q.getNameForDisplay=function(){
return this.getDisplayName()||"(Unnamed Contact)"
};
Q.getEmail=function(){
var a=this.getChildNode("Emails");
if(a)if((a=a.getChildNodes())&&a.getCount()>0)return a.getByIndex(0).getChildNodeValue("Address");
return j
};
Q.getId=function(){
return this.getChildNodeValue("Id")
};
Q.getEmails=function(){
var a=[],b=this.getChildNode("Emails");
if(b){
b=b.getChildNodes();
for(var c=0,e=b.getCount();
c<e;
++c)a[w](b.getByIndex(c).getChildNodeValue("Address"))
}
return a
};
Q.getAffinity=function(){
return this.getChildNodeValue("Affinity")
};
Q.getMailsSent=function(){
return this.getChildNodeValue("MailsSent")
};
var Eo=function(a){
if(a!=j&&!ge(a.getChildNodeValue("Month"))&&!ge(a.getChildNodeValue("Day")))return i;
return k
}
,Fo=function(a){
return a!=j&&(!ge(a.getChildNodeValue("Month"))||!ge(a.getChildNodeValue("Day"))||!ge(a.getChildNodeValue("Year")))
};
vo[y].hasValidBirthday=function(){
var a=this.getChildNode("Birthday");
return Eo(a)
};
vo[y].hasIncompleteDates=function(){
var a=this.getChildNode("Dates");
if(!a)return k;
a=a.getChildNodes();
for(var b=0;
b<a.getCount();
b++){
var c=a.getByIndex(b);
if(Fo(c)&&!(Eo(c)&&!ge(c.getChildNodeValue("Year"))))return i
}
return k
};
var Go=function(a){
var b=a.getChildNodeValue("Month"),c=a.getChildNodeValue("Day"),e=a.getChildNodeValue("Year");
if(!Eo(a))return k;
a=[31,29,31,30,31,30,31,31,30,31,30,31];
b=Ee(b);
var f=Ee(c);
if(ge(e))return f>a[b-1]?i:k;
e=new jo(Ee(e),b-1,1);
if(c>e.getNumberOfDaysInMonth())return i;
return k
};
Q=vo[y];
Q.hasAnyDateWithWrongDayRange=function(){
var a=this.getChildNode("Dates");
if(!a)return k;
a=a.getChildNodes();
for(var b=0;
b<a.getCount();
b++){
var c=a.getByIndex(b);
if(Go(c))return i
}
return k
};
Q.hasBirthdayWithWrongDayRange=function(){
var a=this.getChildNode("Birthday");
if(!a)return k;
return Go(a)
};
Q.hasEmptyDates_=function(){
var a=this.getChildNode("Dates");
if(a==j)return i;
a=a.getChildNodes();
for(var b=0;
b<a.getCount();
b++){
var c=a.getByIndex(b);
if(Eo(c)&&!ge(c.getChildNodeValue("Year")))return k
}
return i
};
Q.isEmpty=function(){
for(var a=0;
a<wo[x];
a++)if(this.getChildNodeValue(wo[a]))return k;
if(this.hasValidBirthday())return k;
if(!this.hasEmptyDates_())return k;
for(var b in zo){
var c=this.getChildNode(b);
if(c){
var e=zo[b].Primary;
for(a=0;
a<c.getCount();
a++){
var f=c.getByIndex(a);
if(f)for(var g=0;
g<e[x];
g++)if(f.getChildNodeValue(e[g]))return k
}
}
}
return i
};
Q.isInGroup=function(a){
if(a=="^All")return i;
if(a=="^Collect")return this.getChildNode("Groups").getChildNode("^Mine")==j;
return this.getChildNode("Groups").getChildNode(a)!=j
};
Q.isDomainContact=function(){
return this.getChildNodeValue("EntryType")=="DOMAIN_CONTACT"
};
Q.isDomainGroup=function(){
return this.getChildNodeValue("EntryType")=="DOMAIN_GROUP"
};
Q.isDomainEntity=function(){
return this.isDomainContact()||this.isDomainGroup()
};
Q.deriveInfoFromEmails=function(){
var a=this.getChildNode("Emails");
if(a)for(var b=W("$UserData/AspDomain").getValue(),c=W("$UserData/Email").getValue(),e=0;
e<a.getCount();
e++){
var f=a.getByIndex(e),g=f.getChildNodeValue("Address");
if(ce(g,"@gmail.com")||ce(g,"@googlemail.com")||b&&ce(g,"@"+b))f.setChildNode("CanChat",i);
g==c&&this.setChildNode("Me",i)
}
};
Q.determineDomainContactType=function(){
if(this.isDomainContact()){
var a=this.getEmail(),b=W("$UserData/AspDomain").getValue();
a&&b&&ce(a,"@"+b)?this.setChildNode("DomainUser",i):this.setChildNode("DomainSharedContact",i)
}
};
Q.getFirstMatchingEmail=function(a){
if(!a)return this.getEmail();
var b=this.getEmails();
a=a[zd]();
for(var c=0,e=b[x];
c<e;
c++){
var f=b[c];
if(f)if(be(f[zd](),a))return f
}
return this.getEmail()
};
Q.getAsEmailString=function(a,b,c){
a=a?this.getDisplayName():j;
return Ho(this.getFirstMatchingEmail(c),a,b)
};
Q.clearInterleavedData=function(){
this.setChildNode("InterleavedProfileIds",{
}
);
this.setChildNode("InterleavedProfileLabels",[]);
this.setChildNode("InterleavedProfileData",{
}
);
this.setIsInterleavedProfileDataLoaded(k)
};
Q.hasInterleavedProfileId=function(a){
var b=this.getChildNode("InterleavedProfileIds");
return b.getChildNodeValue(a)||k
};
Q.setInterleavedProfileId_=function(a){
var b=this.getChildNode("InterleavedProfileIds");
b.setChildNode(a,i)
};
Q.hasUnderleavedProfileId=function(a){
var b=this.getChildNode("UnderleavedProfileIds");
return b.getChildNodeValue(a)||k
};
Q.setUnderleavedProfileId_=function(a){
var b=this.getChildNode("UnderleavedProfileIds");
b.setChildNode(a,i)
};
Q.addUnderleavedProfile=function(a){
if(!this.hasUnderleavedProfileId(a.getId())){
var b="UnderleavedProfiles",c=this.getChildNode(b);
if(!c){
c=new fi({
}
,b);
this.setChildNode(b,c)
}
c.add(a);
this.setUnderleavedProfileId_(a.getId())
}
};
Q.addProfileForInterleavedView=function(a){
if(!this.hasInterleavedProfileId(a.getId())){
for(var b=this.createNewLabelForProfile_(a),c=a.getId(),e=xo[Kb](wo),f=0;
f<e[x];
f++){
var g=e[f],h=a.getChildNodeValue(g),n=j;
if(h){
if(Rd(h))n=h.getJsObject?h.getJsObject():h;
else{
n={
};
n[g]=h
}
h=[n];
this.addInterleavedProfileDataToContact_(g,h,c,b)
}
}
e=Bo[Kb](ff(Ao));
for(f=0;
f<e[x];
f++){
g=e[f];
if(h=a.getChildNode(g)){
h=h.getJsObject();
this.addInterleavedProfileDataToContact_(g,h,c,b)
}
}
this.setInterleavedProfileId_(c)
}
};
Q.addInterleavedProfileDataToContact_=function(a,b,c,e){
var f=this.getChildNode("InterleavedProfileData",i),g=f.getChildNode(a);
if(!g){
g=new fi({
}
,a);
f.setChildNode(a,g)
}
for(a=0;
a<b[x];
a++){
b[a].ProfileSource=c;
b[a].ProfileSourceLabel=e;
g.add(b[a])
}
};
Q.createNewLabelForProfile_=function(a){
var b="InterleavedProfileLabels",c=this.getChildNode(b);
if(!c){
c=new fi({
}
,b);
this.setChildNode(b,c)
}
var e=a.getId();
b=c.getCount();
b=ma(b+1+1)[ud]("*");
var f={
};
f.ProfileId=e;
f.Label=b;
e="personal";
var g=a.getNameForDisplay()+" <"+a.getEmail()+">",h=$[C]("$UserData/AspDomainTitle");
if(a.isDomainContact())e=h?h:"shared";
a='Information from "'+(g+('" ('+(e+" contact).")));
f.LabelDisplayName=a;
c.add(f);
return b
};
var Jo=function(a,b){
var c=Io(a,b);
if(c!=0)return c;
var e=a.getDisplayName();
c=b.getDisplayName();
if(e){
if(!c)return-1
}
else return c?1:0;
e=e[zd]();
c=c[zd]();
return e==c?0:e<c?-1:1
}
,Ko=function(a,b){
var c=Io(a,b);
if(c!=0)return c;
c=b.getAffinity()-a.getAffinity();
if(c!=0)return c;
return Jo(a,b)
}
,Io=function(a,b){
var c=a.isDomainEntity()?1:0,e=b.isDomainEntity()?-1:0;
return c+e
};
var Oo=function(){
this.serverPath_=Wl().getServerBase()[db]();
this.useGroups_=this.useThumbs_=k;
this.fieldSet_=j;
this.maxContacts_=500;
this.getUserPrefs_=this.supportDomainGroups_=this.supportDomainContacts_=this.showDomainContacts_=k;
this.newContactCount_=0;
this.selectedCount_=50;
this.requiredFields_=[];
this.includeGrandCentral_=k;
this.useXmlHttp_=!be(this.serverPath_[db](),"http");
this.selectedContacts_=new Lo;
this.selectedGroup_=new Mo;
this.contactNodes_=new No;
wk[J](this,this.contactNodes_,"Contacts");
V().addDataSource(this);
this.data_={
};
var a=new wk(this.data_,"ContactData");
V().addDataSource(a);
this.createTempGroup();
this.setupDatesData_();
this.privateContactsMap_=new to
};
U(Oo,wk);
Oo[y].setupDatesData_=function(){
for(var a={
Days:[],Months:[],Years:[]
}
,b=1;
b<=31;
b++)a.Days[w]({
Day:b
}
);
var c=(new Date)[Fc]();
for(b=1900;
b<=c;
b++)a.Years[w]({
Year:b
}
);
V().addDataSource(new wk(a,"$DateData"))
};
var Po=j,Qo=/\/b\/[^\/]+\/u\/[^\/]+/,Ro=/\/b\/[^\/]+/,So=/\/u\/\d+/,Lm=function(){
Po||(Po=new Oo);
return Po
};
Q=Oo[y];
Q.getContact=function(a){
return this.getChildNodes().get(a)
};
Q.setUseThumbs=function(a){
this.useThumbs_=a
};
Q.setUseInitialEmbeddedData=function(a){
this.useInitialEmbeddedData_=a
};
Q.setUseGroups=function(a){
this.useGroups_=a
};
Q.setMaxContacts=function(a){
this.maxContacts_=a
};
Q.setRequiredFields=function(a){
this.requiredFields_=a||[]
};
Q.setSupportDomainContacts=function(a){
this.supportDomainContacts_=a
};
Q.setSupportDomainGroups=function(a){
this.supportDomainGroups_=a
};
Q.domainContactsEnabled=function(){
return this.showDomainContacts_&&this.supportDomainContacts_
};
Q.domainGroupsEnabled=function(){
return this.showDomainContacts_&&this.supportDomainGroups_
};
Q.setGetAllFields=function(a){
this.fieldSet_=a?"ALL":j
};
Q.setGetUserPrefs=function(a){
this.getUserPrefs_=a
};
Q.setIncludeGrandCentral=function(a){
this.includeGrandCentral_=a
};
Q.setFieldsToRequest=function(a){
this.fieldSet_=a
};
Q.getChildNodes=function(a){
if(!a||a=="*")return this.contactNodes_;
else if(a[E]("*")==-1)return(a=this.getChildNode(a))?new Sf([a]):new Rf;
else d(l("Selector not supported yet ("+a+")"))
};
Q.getChildNodeValue=function(a){
a=this.contactNodes_.get(a);
return a==j?j:a.get()
};
Q.isList=function(){
return i
};
Q.getServerPath=function(){
return this.serverPath_
};
Q.getFfeServerPath=function(){
return this.ffeServerPath_
};
Q.computeFfeServerPath_=function(){
var a=this.serverPath_,b=$[C]("$UserData/AspDomain"),c=a[nc](Qo),e=a[nc](Ro),f=a[nc](So);
c=c||e||f||"";
if(b)if(be(a,"/a/"))a="/a/c/"+b+c;
else{
if(be(a,"/mail/"))a="/mail/c"+c
}
else if(be(a,"/mail/"))a="/mail/c"+c;
this.ffeServerPath_=a
};
Q.enableRichSearchLogging=function(a){
this.isRichSearchLoggingEnabled_=a
};
Q.isRichSearchLoggingEnable=function(){
return!!this.isRichSearchLoggingEnabled_
};
Q.getContactsUri_=function(a,b,c){
var e=this.getServerPath();
if(this.domainContactsEnabled())e=this.getFfeServerPath();
e=new Sh(e+"/data/contacts");
var f=e.getQueryData();
f.set("thumb",m(this.useThumbs_));
f.set("groups",m(this.useGroups_));
this.fieldSet_&&f.set("show",this.fieldSet_);
f.set("psort","DisplayName");
f.set("max",m(a||this.maxContacts_));
f.set("out","js");
f.set("rf",this.requiredFields_[ud](","));
if(b){
f.set("tok",b);
this.allContactsLoaded_&&f.set("cl","false");
this.domainContactsEnabled()&&
f.set("cd","true");
this.domainGroupsEnabled()&&f.set("dg","true");
this.isRichSearchLoggingEnable()&&f.set("sr","true")
}
c&&f.set("ud","false");
this.getUserPrefs_&&f.set("up","true");
this.includeGrandCentral_&&f.set("gc","true");
return e
};
Q.setupListeners_=function(){
if(!this.listening_){
var a=V();
new To("Groups","$ContactReq/Body/Groups","$ContactReq/Body/Groups");
new To("AuthToken","$ContactReq/Body/AuthToken","$ContactReq");
new To("ExtraData","$ContactReq/Body/ExtraData","$ContactReq");
a.aliasDataSource("$UserData","$ContactReq/Body/UserData");
a.aliasDataSource("$UserProfile","$ContactReq/Body/UserProfile");
this.groupsDataPath_="$Groups";
this.tokenExpr_=W("$AuthToken/Value");
this.groupsExpr_=W(this.groupsDataPath_);
a.addListener(T(this.dataReceived_,
this),"$ContactReq");
a.addListener(T(this.moreDataReceived_,this),"$ContactAppend");
a.addListener(T(this.groupsChanged_,this),this.groupsDataPath_);
var b=this;
a=Sk();
a[M]("ADD_SELECTED_CONTACTS_TO_GROUP",function(c){
b.addSelectedContactsToGroup(c.groupId)
}
);
a[M]("SHOW_NICKNAME",function(){
$[u]("$TempContact/ShowDefaultNickName",i)
}
);
a[M]("ADD_EMAIL",function(){
b.addRepeatedContactField_(b.getTempContact(),"Emails","HOME",k)
}
);
a[M]("REMOVE_EMAIL",function(c){
b.removeRepeatedContactField_(b.getTempContact(),
"Emails",c.dataName)
}
);
a[M]("ADD_PHONE",function(){
b.addRepeatedContactField_(b.getTempContact(),"Phones","MOBILE")
}
);
a[M]("REMOVE_PHONE",function(c){
b.removeRepeatedContactField_(b.getTempContact(),"Phones",c.dataName)
}
);
a[M]("ADD_LINK",function(){
b.addRepeatedContactField_(b.getTempContact(),"Links","HOME")
}
);
a[M]("REMOVE_LINK",function(c){
b.removeRepeatedContactField_(b.getTempContact(),"Links",c.dataName)
}
);
a[M]("SHOW_OR_ADD_IM",function(){
$[C]("$TempContact/ShowIms")?b.addRepeatedContactField_(b.getTempContact(),
"Ims"):b.showContactField_("Ims")
}
);
a[M]("ADD_IM",function(){
b.addRepeatedContactField_(b.getTempContact(),"Ims",ba,k,"GTALK")
}
);
a[M]("REMOVE_IM",function(c){
b.removeRepeatedContactField_(b.getTempContact(),"Ims",c.dataName)
}
);
a[M]("ADD_ADDRESS",function(){
b.addRepeatedContactField_(b.getTempContact(),"Addresses","HOME")
}
);
a[M]("REMOVE_ADDRESS",function(c){
b.removeRepeatedContactField_(b.getTempContact(),"Addresses",c.dataName)
}
);
a[M]("SHOW_OR_ADD_RELATION",function(){
$[C]("$TempContact/ShowRelations")?
b.addRepeatedContactField_(b.getTempContact(),"Relations","SPOUSE"):b.showContactField_("Relations")
}
);
a[M]("SHOW_OR_ADD_DATE",function(){
$[C]("$TempContact/ShowDates")?b.addRepeatedContactField_(b.getTempContact(),"Dates","ANNIVERSARY"):b.showContactField_("Dates")
}
);
a[M]("ADD_RELATION",function(){
b.addRepeatedContactField_(b.getTempContact(),"Relations","SPOUSE")
}
);
a[M]("REMOVE_RELATION",function(c){
b.removeRepeatedContactField_(b.getTempContact(),"Relations",c.dataName)
}
);
a[M]("SHOW_OR_ADD_OTHER",
function(){
$[C]("$TempContact/ShowOthers")?b.addRepeatedContactField_(b.getTempContact(),"Others","HOME"):b.showContactField_("Others")
}
);
a[M]("ADD_OTHER",function(){
b.addRepeatedContactField_(b.getTempContact(),"Others","HOME")
}
);
a[M]("REMOVE_OTHER",function(c){
b.removeRepeatedContactField_(b.getTempContact(),"Others",c.dataName)
}
);
a[M]("SHOW_OR_ADD_CUSTOM",function(){
$[C]("$TempContact/ShowCustomFields")?b.addRepeatedContactField_(b.getTempContact(),"CustomFields"):b.showContactField_("CustomFields")
}
);
a[M]("ADD_CUSTOM",function(){
b.addRepeatedContactField_(b.getTempContact(),"CustomFields")
}
);
a[M]("REMOVE_CUSTOM",function(c){
b.removeRepeatedContactField_(b.getTempContact(),"CustomFields",c.dataName)
}
);
a[M]("SHOW_IF_ENRICHED_CONTACTS_EXP",function(c){
Wa(c.element[H],"")
}
);
a[M]("ADD_DATE",function(){
b.addRepeatedContactField_(b.getTempContact(),"Dates","ANNIVERSARY")
}
);
a[M]("REMOVE_DATE",function(c){
b.removeRepeatedContactField_(b.getTempContact(),"Dates",c.dataName)
}
);
a[M]("PICTURE_ERROR",T(this.handlePictureError_,
this));
this.listening_=i
}
};
Q.showContactField_=function(a){
$[u]("$TempContact/Show"+a,i);
var b=V();
b.fireDataChange("$TempContact/"+a)
};
Q.handlePictureError_=function(a){
var b=W("$Contacts/"+a.contactId).getNode();
if(b){
b.setHasNoPicture();
b=V();
b.fireDataChange("$Contacts/"+a.contactId+"/MaybeHasPicture")
}
};
Q.getGmailUrl=function(){
return W("$UserData/GmailUrl").getValue()
};
Q.isUserInExperiment=function(a){
var b=W("$UserData/Experiments").getValue();
return!!b&&Qe(b,a)
};
wa(Q,function(a,b,c,e){
this.setupListeners_();
var f=a||1;
a=f==4;
var g=f==3;
e=c&&this.domainContactsEnabled()&&!e;
if(!((g||a)&&this.allContactsLoaded_&&!e))if(!this.hasAttemptedLoad_||f!=1){
e=a?"ContactAppend":"ContactReq";
if(a){
$[u]("$ContactData/PendingLongRequest",i);
$[u]("$ContactData/AppendRequestDone",k)
}
else{
$[u]("$ContactData/Loaded",k);
$[u]("$ContactData/Loading",i)
}
if(f==1&&this.useInitialEmbeddedData_){
this.waitingForEmbeddedData_=i;
this.attemptToLoadEmbeddedData_()
}
else{
f=V();
b=this.getContactsUri_(b,
c,a);
if(this.useXmlHttp_){
b.setParameterValue("jsx","true");
this.requestData_=new ji(b,e,"&&&START&&&","&&&END&&&")
}
else this.requestData_=new gn(b,e);
f.addDataSource(this.requestData_,i);
this.requestData_[Eb]();
this.hasAttemptedLoad_=i
}
}
}
);
Q.attemptToLoadEmbeddedData_=function(){
if(!this.hasAttemptedLoad_&&this.waitingForEmbeddedData_&&this.requestData_){
this.requestData_[Eb]();
this.hasAttemptedLoad_=i
}
};
Q.handleInitialEmbeddedData=function(a){
var b=V();
this.requestData_=new Uo(a,"ContactReq");
b.addDataSource(this.requestData_,i);
this.attemptToLoadEmbeddedData_()
};
Q.dataReceived_=function(a){
V().runWithoutFiringDataChanges(T(this.loadInitialData_,this,a));
a=$.getNode("$ExtraData/NavLinks",i);
if(Z("additional-nav-links")&&a){
xa(Z("additional-nav-links"),a.get());
a=$.getNode("$ExtraData/BlInfo",i);
qa(Z("additional-nav-links"),a.get())
}
this.showDomainContacts_=!!W("$UserData/ShowDomainContacts").getValue();
this.computeFfeServerPath_();
$[u]("$ContactData/Loading",k);
(a=W("$ContactReq/Body").getNode())&&a.setChildNode("Contacts",j);
Uf.info("About to fire data change");
V().fireDataChange("$Contacts");
V().fireDataChange("$Groups");
V().fireDataChange("$SelectedContactCount");
V().fireDataChange("$UserPrefs");
Uf.info("Done firing data change");
$[u]("$ContactData/Loaded",i)
};
Q.moreDataReceived_=function(){
var a=W("$ContactAppend/Body/Contacts").getValue();
Uf.info("Starting adding additional contacts");
if(a)this.contactNodes_=this.meldContactLists(this.contactNodes_,a);
(a=W("$ContactAppend/Body/NameSegments").getValue())&&this.updateNameSegments(a);
Uf.info("Ending adding additional contacts");
V().fireDataChange("$Contacts");
$[u]("$ContactData/PendingLongRequest",k);
$[u]("$ContactData/AppendRequestDone",i)
};
Q.loadInitialData_=function(a){
var b=this.selectedContacts_.getChildNodes(),c=b.getCount(),e=[];
if(c>0){
for(var f=0;
f<c;
f++)e[f]=b.getByIndex(f).getId();
this.unselectContacts()
}
this.contactNodes_[ad]();
Uf.info("Starting contact add");
b=W("$ContactReq/Body/Contacts").getValue()||[];
Uf.info("Starting contact updates");
f=0;
for(c=b[x];
f<c;
f++)this.addContactOnLoad_(b[f]);
(f=W("$ContactReq/Body/NameSegments").getValue())&&this.updateNameSegments(f);
Uf.info("Ended contact add");
this.allContactsLoaded_=
b[x]==this.getAllContactsCount_();
this.newGroupData(a);
this.newUserPrefsData(a);
this.contactsAfterLoad_&&this.parseContacts(this.contactsAfterLoad_,"^Temp");
for(f=0;
f<e[x];
f++)if(a=this.contactNodes_.get(e[f])){
this.selectContact(a,i);
this.associateGroupsToContact_(a)
}
};
Q.getAllContactsCount_=function(){
var a=$.getNode("$Groups/^All/Count");
if(a)return a.get();
return $[C]("$Groups/^Mine/Count")+$[C]("$Groups/^Collect/Count")
};
Q.allPrivateContactsLoaded=function(){
return this.getPrivateContactCount()==this.getAllContactsCount_()
};
Q.newGroupData=function(a){
a=(a=W(a+"/Body/Groups").getNode())?a.getJsObject():[];
a=hi(a,"$Groups");
V().addDataSource(a)
};
Q.newUserPrefsData=function(a){
a=(a=W(a+"/Body/UserPrefs").getNode())?a.getJsObject():[];
a=hi(a,"$UserPrefs");
V().addDataSource(a)
};
Q.groupsChanged_=function(){
Uf.info("Starting groupsChanged");
this.hasGroups_=i;
this.groupMap_={
};
for(var a=this.groupsExpr_.getNode().getChildNodes(),b=0;
b<a.getCount();
b++){
var c=a.getByIndex(b);
this.groupMap_[c.getChildNodeValue("id")]=c
}
this.associateGroups_();
Uf.info("Ending groupsChanged")
};
Q.associateGroups_=function(){
for(var a=this.contactNodes_.getCount(),b=0;
b<a;
b++){
var c=this.contactNodes_.getByIndex(b);
this.associateGroupsToContact_(c)
}
};
Q.associateGroupsToContact_=function(a){
a=a.getChildNode("Groups",i).getChildNodes();
for(var b=0;
b<a.getCount();
b++){
var c=a.getByIndex(b);
if(c.get()&&c.getChildNodes().getCount()>0){
var e=this.groupMap_[c.getChildNodeValue("id")];
if(e){
var f=c.getChildNode("ref");
if(f&&f.getChildNodeValue("Name")!=c.getChildNodeValue("Name")){
c.getChildNodes().setNode("ref",j);
f=j
}
if(!f||!f.get())c.getChildNodes().add(Vf(e,"ref"))
}
}
}
};
Q.addContactOnLoad_=function(a){
this.contactNodes_.update(new vo(a,this),i)
};
Q.updateContact=function(a){
var b=a.getJsObject?a.getJsObject():a.root_?a.root_:a,c=new vo(b,this);
b=b.id;
var e=k,f=k,g=j,h=this.contactNodes_.get(b);
if(h){
if(c.isDomainContact()){
c.setChildNode("InterleavedProfileIds",h.getChildNodeValue("InterleavedProfileIds"));
c.setChildNode("InterleavedProfileLabels",h.getChildNodeValue("InterleavedProfileLabels"));
c.setChildNode("InterleavedProfileData",h.getChildNodeValue("InterleavedProfileData"))
}
else this.removePersonalContactFromMultimap_(h);
f=this.isContactInGroup(h,
"^Freq");
(e=this.isContactInGroup(h,"^Temp"))&&this.selectContact(h,k);
g=h.getChildNodeValue("RosterState")
}
var n=this.contactNodes_.getCount();
if(c.isDomainContact()){
var o=c.getChildNode("Emails");
if(!h&&o){
var s={
}
,A={
};
this.mapExistingContacts_(this.contactNodes_.list_,s,A,k);
for(s=0;
s<o.getCount();
++s){
var G=o.getByIndex(s).getChildNodeValue("Address");
if(G=A[G])return G
}
}
}
else this.addPersonalContactToMultimap_(c);
this.contactNodes_.update(c,k);
e&&this.selectContact(c,i);
f&&this.setContactInGroup(c,
"^Freq",i);
g&&a.setChildNode("RosterState",g);
h&&b==W("$CurrentContactId").getValue()&&S[yb](function(){
V().fireDataChange("$CurrentContact")
}
,5);
V().fireDataChange(c.getDataPath());
this.contactNodes_.getCount()!=n&&V().fireDataChange("$Contacts/count()");
return c
};
Q.notifyContactChanged_=function(a){
if(a){
var b=a.getId(),c=a.getEmails()[ud](",");
a=a.getName();
Sk()[Oc]("CONTACT_CHANGED","id",b,"emails",c,"name",a)
}
else Sk()[Oc]("CONTACT_CHANGED")
};
Q.notifyGroupChanged_=function(){
Sk()[Oc]("GROUP_CHANGED")
};
Q.addContact=function(a){
this.newContactCount_++;
var b="temp."+this.newContactCount_;
a.setChildNode("Id",b);
return a=this.updateContact(a)
};
Q.createTempContact=function(a){
var b=(a=a?$.getNode(a):j)?a.getJsObject():{
}
,c=Vd(b);
Vo(c,"NickNames");
Vo(c,"Emails");
Vo(c,"Phones");
Vo(c,"Ims");
Vo(c,"Addresses");
Vo(c,"Others");
Vo(c,"Relations");
Vo(c,"CustomFields");
Vo(c,"Links");
Vo(c,"Dates");
b="$TempContact";
c=new vo(c,j,b);
if(a){
var e="InterleavedProfileData";
c.setChildNode(e,a.getChildNode(e));
e="InterleavedProfileLabels";
c.setChildNode(e,a.getChildNode(e))
}
a=V();
a.runWithoutFiringDataChanges(T(this.createTempContactImpl_,this,c));
a.addDataSource(c);
a.fireDataChange(b);
return c
};
Q.createTempContactImpl_=function(a){
a.getChildNodeValue("DefaultNickName")&&a.setChildNode("ShowDefaultNickName",i);
this.ensureOneRepeatedContactField_(a,"NickNames","DEFAULT");
this.ensureOneRepeatedContactField_(a,"Emails","HOME");
this.ensureOneRepeatedContactField_(a,"Phones","MOBILE");
this.ensureOneRepeatedContactField_(a,"Ims",ba,"GTALK");
this.ensureOneRepeatedContactField_(a,"Addresses","HOME");
this.ensureOneRepeatedContactField_(a,"Others","HOME");
this.ensureOneRepeatedContactField_(a,"Relations",
"SPOUSE");
this.ensureOneRepeatedContactField_(a,"CustomFields");
this.ensureOneRepeatedContactField_(a,"Links","HOME");
this.ensureOneRepeatedContactField_(a,"Dates","ANNIVERSARY");
var b=$.getNode("$CurrentGroup");
b&&!this.isGroupLocked(b)&&this.setContactInGroup(a,b.getChildNodeValue("id"),i)
};
Q.createTempGroup=function(){
var a={
};
a=new wk(a,"$TempGroup");
V().addDataSource(a)
};
Q.saveContact=function(a,b,c){
if(a.get()){
a=a.mergeIds_?new Wo(this,a,b,c):new Xo(this,a,b,c);
a[pc]()
}
};
Q.onPhotoSaved=function(a,b){
if(a){
Sl().add("Picture has been added.","INFO");
this.updateContactPicture_(b)
}
else Sl().add("Error while saving your picture.","ERROR")
};
Q.onPhotoDeleted=function(a,b){
if(a){
this.updateContactPicture_(b);
Sl().add("Picture has been deleted.","INFO")
}
else Sl().add("Error while deleting picture.","ERROR")
};
Q.updateContactPicture_=function(a){
var b=this.contactNodes_.get(a.Id);
if(b){
b.setChildNode("Picture",a.Picture);
b.setChildNode("Photo",a.Photo);
b.setChildNode("EvergreenPhoto",a.EvergreenPhoto);
b.refreshPicture();
a=V();
a.fireDataChange("$CurrentContact/Picture");
a.fireDataChange("$CurrentContact/ForcedPicture");
a.fireDataChange("$CurrentContact/MaybeHasPicture");
return b
}
};
Q.onPhotoSuggested=function(a){
a?Sl().add("Successfully sent picture suggestion.","INFO"):Sl().add("Error while sending your suggestion.","ERROR")
};
Q.getDeleteConfirmationMessage_=function(a,b,c){
if(b)if(a==1)return"Are you sure you want to delete this contact?\n\nDeleting this contact will delete it from other Google apps you may use like Picasa, Reader, Google chat, Latitude, Google Voice, Mobile Sync (including iPhones and Android) and Gmail autocomplete.\n\nThis action cannot be undone.";
else return a="Are you sure you want to delete these "+(a+" contacts?\n\nDeleting these contacts will delete them from other Google apps you may use like Picasa, Reader, Google chat, Latitude, Google Voice, Mobile Sync (including iPhones and Android) and Gmail autocomplete.\n\nThis action cannot be undone.");
else if(a==1)return a='Are you sure you want to delete the contact "'+(c+'"? This action cannot be undone.');
else return a="Are you sure you want to delete these "+(a+" contacts? This action cannot be undone.")
};
Q.deleteContact=function(a,b,c){
var e=this.contactNodes_.get(a);
if(e){
e=e.getNameForDisplay();
if(confirm(this.getDeleteConfirmationMessage_(1,this.isUserInExperiment("deleteconfirmation"),e))){
a=new Yo(this,a,b,c);
a[pc]()
}
}
};
Q.ignoreSelectedContactsAsSuggestions=function(a,b){
var c=this.selectedContacts_.getChildNodes(),e=c.getCount();
if(e>0){
for(var f=[],g=0;
g<e;
g++){
var h=c.getByIndex(g);
f[w](h.getChildNodeValue("id"))
}
c=new Zo(this,f,a,b);
c[pc]()
}
};
Q.deleteSelectedContacts=function(a,b){
for(var c=this.selectedContacts_.getChildNodes(),e=c.getCount(),f=[],g=0,h=0;
h<e;
h++){
var n=c.getByIndex(h);
if(n.isDomainContact())g++;
else f[w](n)
}
h=W("$UserData/AspDomainTitle").getValue();
var o;
if(f[x]>0){
o=f[0].getDisplayName();
o=this.getDeleteConfirmationMessage_(f[x],this.isUserInExperiment("deleteconfirmation"),o)
}
if(g>0){
g="You cannot delete "+(h+" contacts.");
o=g+"\n"+o
}
if(f[x]>0&&confirm(o)){
g=[];
for(h=0;
h<f[x];
h++){
o=f[h].getChildNodeValue("id");
g[w](o)
}
f=
new Yo(this,g,a,b);
f[pc]()
}
};
Q.contactDeleted_=function(a){
var b=this.getContact(a);
this.removePersonalContactFromMultimap_(b);
this.contactNodes_[Uc](a);
this.selectedContacts_.setChildNode(a,j)
};
Q.mergeSelectedContactsPreview=function(a,b){
var c=this.selectedContacts_.getChildNodes(),e=c.getCount();
if(e>1&&e<=10){
for(var f=[],g=0;
g<e;
g++){
var h=c.getByIndex(g).getChildNodeValue("id");
f[w](h)
}
c=new $o(this,f,a,b);
c[pc]()
}
};
Q.isGroupNameInUse=function(a,b){
var c=this.groupsExpr_.getNode().getChildNodes();
a=a[zd]();
for(var e=0;
e<c.getCount();
e++){
var f=c.getByIndex(e);
if(a==f.getChildNodeValue("Name")[zd]()&&b!=f.getChildNodeValue("id"))return i
}
return k
};
Q.addContactByIdToGroup=function(a,b,c){
if(b=="^New"){
if(a=ap(this)){
c=new bp(this,ba,"NEW",a,c);
c[pc]()
}
}
else{
c=new bp(this,b,"ADD","",c);
c[pc]()
}
};
Q.addSelectedContactsToGroup=function(a){
if(a){
a=this.getGroupName(a);
a=new bp(this,a,"ADD");
a[pc]()
}
};
Q.removeSelectedContactsFromGroup=function(a,b){
if(a){
var c=new bp(this,a,"REMOVE",ba,b);
c[pc]()
}
};
Q.getGroupName=function(a){
return W(this.groupsDataPath_+"/"+a+"/Name").getValue()
};
Q.isGroupLocked=function(a){
return(a=Od(a)?$.getNode("$Groups/"+a):a)&&a.getChildNodeValue("IsLocked")
};
Q.isGroupGrowable=function(a){
return(a=Od(a)?$.getNode("$Groups/"+a):a)&&(!this.isGroupLocked(a)||a.getChildNodeValue("id")=="^Mine")
};
Q.removeContactFromGroup=function(a,b,c){
a=new bp(this,b,"REMOVE",ba,c);
a[pc]()
};
Q.isContactInGroup=function(a,b){
var c=a.getChildNode("Groups",i).getChildNode(b);
return c!=j&&c.getChildNodeValue("id")!=j
};
Q.setContactInGroup=function(a,b,c){
var e=this.isContactInGroup(a,b);
if(c&&!e){
c=a.getChildNode("Groups",i).getChildNode(b,i);
c.setChildNode("value",a.getEmail());
c.setChildNode("id",b)
}
else!c&&e&&a.getChildNode("Groups",i).setChildNode(b,j)
};
Q.selectContact=function(a,b){
a.setChildNode("SelectedCount",this.selectedCount_++);
var c=a.getDataName(),e=b!=j?b:!this.isContactInGroup(a,"^Temp");
this.setContactInGroup(a,"^Temp",e);
if(e){
a.deriveInfoFromEmails();
a.determineDomainContactType()
}
var f=!!this.selectedContacts_.getChildNode(c);
if(e!=f){
e=e?Vf(a,c):j;
this.selectedContacts_.setChildNode(c,e);
$[u]("$SelectedContactCount",this.selectedContacts_.getChildNodes().getCount())
}
};
Q.selectSingleContact=function(a){
var b=a.getDataName();
this.unselectContactsExcept(b);
this.selectContact(a,i)
};
Q.unselectContacts=function(){
this.unselectContactsExceptInternal_(j)
};
Q.unselectContactsExcept=function(a){
this.unselectContactsExceptInternal_(a,k)
};
Q.unselectContactsExceptGroup=function(a){
this.unselectContactsExceptInternal_(a,i)
};
Q.unselectContactsExceptInternal_=function(a,b){
for(var c={
}
,e=this.selectedContacts_.getChildNodes(),f=0;
f<e.getCount();
f++){
var g=e.getByIndex(f),h=g.getDataName(),n=i;
if(a)n=b?!this.isContactInGroup(g,a):n=h!=a;
if(n)c[h]=g
}
for(var o in c)this.selectContact(c[o],k)
};
Q.getSelectedContacts=function(){
return this.selectedContacts_
};
Q.splitContactsFromString_=function(a){
for(var b=k,c=[],e=0,f=-1;
e<a[x];
){
var g=a[Lb](e);
if(g=='"'||g=="'")b=!b;
if(!b&&(g==","||g==";
")){
f<e-1&&c[w](a[Sc](f+1,e));
f=e
}
e++
}
f<e-1&&c[w](a[Sc](f+1,e));
return c
};
Q.parseContacts=function(a){
for(var b={
}
,c=this.getChildNodes(),e=c.getCount(),f=0;
f<e;
f++){
var g=c.getByIndex(f);
b[g.getEmail()]=g
}
a=this.splitContactsFromString_(a);
for(f=0;
f<a[x];
f++){
g=a[f];
e=c=j;
c=g[E]("<");
if(c==-1)c=je(g);
else{
e=je(g[Sc](0,c));
a:{
e=e;
for(var h="\"'",n=h[x],o=0;
o<n;
o++){
var s=n==1?h:h[Lb](o);
if(e[Lb](0)==s&&e[Lb](e[x]-1)==s){
e=e[Sc](1,e[x]-1);
break a
}
}
e=e
}
c=je(g[Sc](c+1,g[E](">",c)))
}
if(c[x]>0){
g=b[c];
if(!g){
g={
Emails:[{
Address:c
}
]
};
if(e)g.Name=e;
g.DisplayName=e||c;
g=hi(g,c);
g=this.addContact(g)
}
this.selectContact(g,i)
}
}
if(this.argz_){
this.formatContacts(-1,"");
this.parseContactsAfterLoad("")
}
};
Q.parseContactsAfterLoad=function(a){
this.contactsAfterLoad_=a
};
Q.formatContacts=function(a,b){
for(var c=this.getChildNodes().getCount(),e=k,f="",g=0;
g<c;
g++){
var h=this.getChildNodes().getByIndex(g);
if(this.isContactInGroup(h,a)){
h=h.getAsEmailString(b=="FULL",i);
if(e)f+=", ";
f+=h;
e=i
}
}
return f
};
Q.isNodeWithPrimary_=function(a){
if(a=="Emails")return i;
return k
};
Q.ensureOneRepeatedContactField_=function(a,b,c,e){
var f=W(b+"/[0]");
f.getNode(a)?a.setChildNode("Show"+b,i):this.addRepeatedContactField_(a,b,c,this.isNodeWithPrimary_(b),e)
};
Q.addRepeatedContactField_=function(a,b,c,e,f){
var g=m(cp++),h=a.getChildNode(b);
if(!h){
h=hi([],b,a);
a.setChildNode(b,h)
}
a=hi({
id:g
}
,g,h);
h.setChildNode(g,a);
c&&a.getChildNode("Type",i).setChildNode("Id",c);
f&&a.getChildNode("Service",i).setChildNode("Id",f);
c=e||k;
a.setChildNode("Primary",c)
};
Q.removeRepeatedContactField_=function(a,b,c){
var e=a.getChildNode(b,i).getChildNode(c);
e=e&&e.getChildNode("Primary");
a.getChildNode(b,i).setChildNode(c,j);
if(b=="Emails"&&e){
a=a.getChildNode(b).getChildNodes();
if(a.getCount()>0){
a=a.getByIndex(0);
a.setChildNode("Primary",i)
}
}
};
Q.getTempContact=function(){
return $.getNode("$TempContact")
};
Q.getCurrentContact=function(){
var a=$[C]("$CurrentContactId");
return this.getContact(a)
};
Q.meldContactLists=function(a,b){
var c={
}
,e={
};
this.privateContactsMap_[ad]();
var f=a.list_;
this.mapExistingContacts_(f,c,e,i);
for(var g=[],h=0,n=b[x];
h<n;
++h){
var o=b[h],s=o.DomainContact,A=o.Emails,G=j;
if(s){
if(A)for(var R=0;
R<A[x];
++R){
G=A[R].Address;
if(G=e[G])break
}
}
else G=c[o.Id];
if(G){
if(!G.isDomainContact()){
!G.getName()&&o.Name&&G.setChildNode("Name",o.Name);
!G.getDisplayName()&&o.DisplayName&&G.setChildNode("DisplayName",o.DisplayName)
}
}
else{
o=new vo(o,this);
g[w](o);
if(s){
if(A)for(R=0;
R<
A[x];
++R){
G=A[R].Address;
e[G]=o
}
}
else this.addPersonalContactToMultimap_(o)
}
}
c=this.meldContactArrays_(f,g);
e=new No;
for(h=0;
h<c[x];
++h)e.update(c[h],i);
return e
};
Q.mapExistingContacts_=function(a,b,c,e){
for(var f=0,g=a[x];
f<g;
++f){
var h=a[f],n=h.getEmails();
if(n){
var o=h.isDomainContact();
if(o)for(o=0;
o<n[x];
++o)c[n[o]]=h;
else{
e&&this.addPersonalContactToMultimap_(h);
b[h.getId()]=h
}
}
}
};
Q.meldContactArrays_=function(a,b){
for(var c=[],e=0,f=0;
f<a[x];
f++){
for(var g=a[f];
e<b[x]&&Jo(g,b[e])>0;
)c[w](b[e++]);
c[w](g)
}
for(;
e<b[x];
)c[w](b[e++]);
return c
};
Q.getPersonalContactsByPrimaryEmail=function(a){
return this.getContactsFromMultiMapByEmail_(this.privateContactsMap_,a)
};
Q.getContactsFromMultiMapByEmail_=function(a,b){
var c=a.get(b),e=[];
if(c)for(var f=0;
f<c[x];
f++){
var g=this.getContact(c[f]);
g&&e[w](g)
}
return e
};
Q.removePersonalContactFromMultimap_=function(a){
(a=a.getId())&&this.privateContactsMap_.removeValue(a)
};
Q.addPersonalContactToMultimap_=function(a){
var b=a.getEmail();
a=a.getId();
b&&a&&this.privateContactsMap_.add(b,a)
};
Q.updateNameSegments=function(a){
for(var b in a){
var c=this.contactNodes_.get(b);
c.setChildNode("NameSegments",a[b])
}
};
Q.clearDomainContacts=function(){
this.contactNodes_.clearDomainContacts()
};
Q.getPrivateContactCount=function(){
return this.contactNodes_.getPrivateContactCount()
};
var Uo=function(a,b){
ei[J](this,{
}
,b,j);
this.extendWith_(a)
};
U(Uo,ei);
wa(Uo[y],function(){
V().fireDataChange(this.getDataName())
}
);
var Lo=function(){
wk[J](this,{
}
,"$SelectedContacts");
V().addDataSource(this);
var a=new wk(0,"SelectedContactCount");
V().addDataSource(a)
};
U(Lo,wk);
Lo[y].isList=function(){
return i
};
var Mo=function(){
wk[J](this,{
}
,"SelectedGroup");
var a=V();
a.addDataSource(this);
a.addListener(T(this.updateMembers_,this),"$CurrentGroup/id")
};
U(Mo,wk);
Mo[y].isList=function(){
return i
};
Mo[y].updateMembers_=function(){
var a=W("$CurrentGroup/id").getValue()||"^Temp";
if(this.groupId_!=a){
this.childNodeList_=new Sf;
for(var b=Lm(),c=b.getChildNodes(),e=0;
e<c.getCount();
e++){
var f=c.getByIndex(e),g=f.getChildNodeValue("id");
b.isContactInGroup(f,a)&&this.setChildNode(g,Vf(f,g))
}
this.groupId_=a;
V().fireDataChange("$SelectedGroup")
}
};
var No=function(){
Tf[J](this,Jo)
};
U(No,Tf);
No[y].update=function(a,b){
var c=a.getChildNodeValue("Id"),e=this.get(c);
if(e)this.setNode(c,a);
else b?this.append(a):this.add(a)
};
Ra(No[y],function(){
Sf[J](this)
}
);
No[y].getPrivateContactCount=function(){
for(var a=0,b=0;
b<this.getCount();
b++){
var c=this.getByIndex(b);
c.isDomainContact()||a++
}
return a
};
No[y].clearDomainContacts=function(){
for(var a=[],b=0;
b<this.getCount();
b++){
var c=this.getByIndex(b);
c.isDomainContact()&&!c.isProfileLoaded()&&a[w](this.getByIndex(b).getId())
}
for(b=0;
b<a[x];
b++)this[Uc](a[b])
};
var dp,ep,gp=function(a,b,c){
this.matchTokens_=[];
this.considerNonPrimaryEmails_=c;
this.fullContactSearch_=i;
a=a[Fb](/\s+/);
for(c=0;
c<a[x];
++c)this.matchTokens_[w](new fp(a[c],b))
};
Q=gp[y];
Q.enableFullContactSearch=function(a){
this.fullContactSearch_=a
};
Q.match=function(a){
this.unmatchedTokens_=Ue(this.matchTokens_);
var b=a.getDisplayName();
if(b){
var c=a.getChildNodeValue("NameSegments");
if(c)for(var e=0,f=0,g=0;
g<c[x];
g++){
f=c[g];
if(this.test_(b[xb](e,f)))return i;
e=f
}
else if(b&&this.test_(b))return i
}
if(g=a.getChildNode("FullName"))if(this.test_(g.getChildNodeValue("GivenName"))||this.test_(g.getChildNodeValue("AdditionalName"))||this.test_(g.getChildNodeValue("FamilyName"))||this.test_(g.getChildNodeValue("PhoneticGivenName"))||this.test_(g.getChildNodeValue("PhoneticAdditionalName"))||
this.test_(g.getChildNodeValue("PhoneticFamilyName"))||this.test_(g.getChildNodeValue("Unstructured")))return i;
if((g=a.getDefaultNickName())&&this.test_(g))return i;
if(b=a.getChildNode("NameAliases")){
b=b.getChildNodes();
for(g=0;
g<b.getCount();
++g)if(this.test_(b.getByIndex(g).get()))return i
}
b=this.considerNonPrimaryEmails_?a.getEmails():[a.getEmail()];
for(g=0;
g<b[x];
g++)if(this.test_(b[g]))return i;
if(!this.fullContactSearch_)return k;
if(b=a.getChildNode("Addresses")){
b=b.getChildNodes();
for(g=
0;
g<b.getCount();
++g){
c=b.getByIndex(g);
if(this.test_(c.getChildNodeValue("Street"))||this.test_(c.getChildNodeValue("City"))||this.test_(c.getChildNodeValue("Region"))||this.test_(c.getChildNodeValue("Postal"))||this.test_(c.getChildNodeValue("Country"))||this.test_(c.getChildNodeValue("Unstructured")))return i
}
}
if(this.matchContactRepeatField_(a,"Links","Url")||this.matchContactRepeatField_(a,"Relations","Name")||this.matchContactRepeatField_(a,"NickNames","Value")||this.matchContactRepeatField_(a,
"CustomFields","Key")||this.matchContactRepeatField_(a,"CustomFields","Value"))return i;
g=fp[y].testPhone;
return this.matchContactRepeatField_(a,"Phones","Number",g)||this.matchContactRepeatField_(a,"Ims","Name")||this.matchContactRepeatField_(a,"Others","Value")||this.matchContactSingleField_(a,"Title")||this.matchContactSingleField_(a,"Company")||this.matchContactSingleField_(a,"Notes")
};
Q.matchContactSingleField_=function(a,b,c){
return(a=a.getChildNodeValue(b))&&this.test_(a,c)
};
Q.matchContactRepeatField_=function(a,b,c,e){
if(a=a.getChildNode(b)){
a=a.getChildNodes();
for(b=0;
b<a.getCount();
++b){
var f=a.getByIndex(b).getChildNodeValue(c);
if(f&&this.test_(f,e))return i
}
}
return k
};
Q.test_=function(a,b){
var c=b||fp[y][lb];
if(!a)return k;
for(var e=0;
e<this.unmatchedTokens_[x];
){
var f=this.unmatchedTokens_[e];
if(c[J](f,a))this.unmatchedTokens_[rd](e,1);
else++e
}
return this.unmatchedTokens_[x]==0
};
var hp=function(a){
gp[J](this,a,k,i);
this.enableFullContactSearch(Lm().isUserInExperiment("fullcontactsearchfordomain"))
};
U(hp,gp);
var fp=function(a,b){
this.token_=ze(a);
this.lcToken_=a[zd]();
var c=b?"(?:^|[\\s@\"'\\-;
,:()|])":"(?:^|[\\s\"'\\-;
,:()|])";
        this.pattern_=la(c+this.token_,"i")
    }
    ;
    fp[y].test=function(a){
        return this.pattern_[lb](a)
    }
    ;
    fp[y].testPhone=function(a){
        if(this.pattern_[lb](a))return i;
        a=a[zd]();
        for(var b=i,c=0;
        c<a[x];
        ++c){
            var e=a[Lb](c);
            if(he(e)){
                if(b){
                    b=0;
                    e=c;
                    for(var f=0;
                    ;
                    ){
                        if(b>=this.lcToken_[x])if(f>=2)return i;
                        else break;
                        else if(e>=a[x])return k;
                        var g=this.lcToken_[Lb](b),h=a[Lb](e);
                        if(g==h){
                            ++b;
                            ++e;
                            ++f
                        }
                        else if(he(g))if(he(h)){
                            if(g!=h)break
                        }
                        else++e;
                        else++b
                    }
                }
                b=k
            }
            else b=i
        }
        return k
    }
    ;
    var lp=function(a,b,c){
        var e=new El(b);
        Y(e,"DOWN_ARROW",T(a.incActiveRow,a));
        Y(e,"UP_ARROW",T(a.decActiveRow,a));
        Y(e,"ENTER",T(ip,j,a));
        Y(e,"STABLE_VALUE",T(jp,j,a));
        c&&Y(e,"PAUSED_VALUE",T(kp,j));
        Y(b,"keypress",function(f){
            var g=f[Dc];
            g==13&&f[Sb]()
        }
        );
        return e
    }
    ,jp=function(a,b){
        a.setToken(b[D])
    }
    ,mp=20,kp=function(a){
        a[D]&&Lm()[Eb](4,mp,a[D])
    }
    ,ip=function(a){
        a.activeRow_!=-1&&a.selectRow(a.activeRow_)
    }
    ,Vo=function(a,b){
        var c=a[b];
        if(c)for(var e=0,f=c[x];
        e<f;
        ++e){
            var g=c[e];
            if(!g.id){
                var h=m(cp++);
                g.id=h
            }
        }
    }
    ,cp=100,rp=function(){
        ul("goog.focus.DataUtil.getData",$[C],"getData");
        ul("goog.focus.DataUtil.setData",$[u],"setData");
        ul("goog.focus.DataUtil.getNode",$.getNode,"getNode");
        ul("goog.focus.DataUtil.dumpData",$.dumpData,"dumpData");
        ul("goog.focus.Ui.setServerBase",Ul.setServerBase,"setServerBase");
        ul("goog.focus.ViewManager.fireEvent",T(Sk()[Oc],Sk()),"doEvent");
        ul("goog.focus.UiUtil.constrainImage",tl,"fixImage");
        ul("goog.ds.DataManager.instance",V(),"dataman");
        ul("goog.focus.ContactUtil.initiateEmail",
        np,"initiateEmail");
        ul("goog.focus.AddContactFieldsMenu",so,"AddContactFieldsMenu");
        ul("goog.focus.CheckboxBinder",Cl,"CheckboxBinder");
        ul("goog.focus.InputBinder",Dl,"InputBinder");
        ul("goog.focus.SelectBinder",Gl,"SelectBinder");
        ul("goog.focus.GeneratingSelectBinder",Hl,"GeneratingSelectBinder");
        ul("goog.focus.RadioBinder",Fl,"RadioBinder");
        ul("goog.focus.InputDecorator",rl,"InputDecorator");
        ul("goog.ui.Zippy",lo,"Zippy");
        Yj.GroupSelectMenu&&ul("goog.focus.GroupSelectMenu.attachAndDisplay",Yj.GroupSelectMenu.attachAndDisplay);
        ul("goog.dom.$",Z);
        ul("goog.ds.DataManager.fireDataChange",T(V().fireDataChange,V()),"fireDataChange");
        ul("goog.focus.ContactUtil.getContacts",op,"getContacts");
        tn||(tn=new sn);
        p[Rb][Rc][E]("Debug=true")!=-1&&tn.setCapturing(i);
        dp=Of("goog.focus.ContactUtil");
        Sk()[M]("MAP_CONTACT",pp);
        Sk()[M]("OPEN_SANITIZED_URL",qp)
    }
    ,sp=function(a,b){
        var c=k,e=a.getChildNode("Groups");
        if(e)if(e=e.getChildNode(b))c=e.getChildNodeValue("id")!=j;
        return c
    }
    ,ap=function(a,b,c){
        c=c||"";
        for(var e=j;
        ;
        ){
            var f="What would you like to name this group?",
            g=f;
            if(e)g=e+"\n"+f;
            c=b!=j?b(g,c):prompt(g,c);
            if(c==j)return j;
            c=je(c);
            e=tp(a,c);
            if(e==j)return c
        }
    }
    ,tp=function(a,b,c){
        var e=j;
        if(b[x]==0)e="You must give a name to the group";
        else if(b[Lb](0)=="^")e="The '^' character is not allowed. Please try another name.";
        else if(b[x]>40)e="Group name must be 40 characters or fewer.";
        else if(a.isGroupNameInUse(b,c))e=a="Group "+(b+" already exists. Please choose another name.");
        return e
    }
    ,wp=function(a,b,c,e){
        b=b?"&thumb=true":"";
        var f=c?"&groups=true":"";
        e=e?
        "&show=ALL":"";
        b=a+"data/contacts?out=js&max=500&psort=Name"+f+b+e;
        e=a+"update/";
        var g=V();
        a=be(a,"http")?new gn(b,"ContactReq"):new ji(b+"&jsx=true","ContactReq","&&&START&&&","&&&END&&&");
        e=new up("$ContactReq/Body/Contacts","$ContactReq",e);
        if(c)new To("Groups","$ContactReq/Body/Groups","$ContactReq/Body/Groups");
        else{
            g.addDataSource(vp(),i);
            g.addListener(function(h){
                if(h=="$Contacts"){
                    h=W("$Contacts").getNodes().getByIndex(0).getChildNodes();
                    dp.info("Adding group data");
                    for(var n=h.getCount(),
                    o=0;
                    o<n;
                    o++){
                        var s=h.getByIndex(o),A=s.getChildNode("Groups");
                        s=s.getChildNodeValue("Name");
                        A.get()||A.set([]);
                        s&&s[zd]()[E]("er")!=-1&&A.getChildNode("ER").set("ER");
                        s&&s[zd]()[E]("z")!=-1&&A.getChildNode("Z").set("Z");
                        o<23&&A.getChildNode("^Freq").set("^Freq")
                    }
                    dp.info("Done adding group data");
                    g.fireDataChange("$Groups")
                }
            }
            ,"$Contacts")
        }
        g.addDataSource(a,i);
        g[Eb]();
        ep=e;
        return p.contacts=e
    }
    ,op=function(){
        return ep
    }
    ,np=function(a){
        var b=new Ig("INITIATE_EMAIL");
        b.to=a;
        if(b=Uk().doEvent(b)){
            a=le(a);
            b=Lm();
            var c=!!$[C]("$UserData/IsGmailUser"),e=23+a[x];
            if(b.isUserInExperiment("toomanytoemail")&&e>1350)Sl().add("Too many contacts are selected.","ERROR");
            else if(c){
                b=b.getGmailUrl();
                a=b+"/?view=cm&tf=1&fs=1&to="+a;
                b=void 0;
                b={
                }
                ;
                Ea(b,b[I]||a[I]||"google_popup");
                ta(b,b[z]||690);
                Xa(b,b[P]||500);
                (a=no(a,b))&&a[zc]()
            }
            else p[kb]("mailto:"+a,"_self")
        }
    }
    ,pp=function(a){
        if(a.address){
            var b=a.address;
            a=a.addressType;
            var c=Lm().getCurrentContact().getNameForDisplay();
            c=c;
            var e=c[x];
            c=e>0&&c[Lb](0)=="("&&
            c[Lb](e-1)==")"?c[Sc](1,e-1):c;
            a=a=a=="HOME"?"Home":a=="WORK"?"Work":"Other";
            a=c+" -- "+a;
            b=b[B](/[\n\r]+/g,",");
            b=b+" ("+a+")";
            a=new Sh("http://maps.google.com/maps");
            a.setParameterValue("q",b);
            no(a[db]())
        }
    }
    ,qp=function(a){
        a=new Sh(a.url);
        a=ve(a[db](),":")?a[db]():"http://"+a[db]();
        no(a)
    }
    ,Ho=function(a,b,c){
        if(!a)return j;
        if(b&&b!=a){
            if(c)b='"'+b+'"';
            a=b+" <"+a+">"
        }
        else a=a;
        return a
    }
    ,up=function(a,b,c){
        this.contactNodes_=new Sf;
        wk[J](this,this.contactNodes_,"Contacts");
        this.primaryDataPath_=a;
        this.primaryDataListenPath_=
        b;
        this.selectedDs_=new xp(this);
        var e=V();
        e.addDataSource(this);
        e.addDataSource(this.selectedDs_);
        e.addListener(T(this.addAllContacts_,this,a),b);
        this.selectionCount_=0;
        new To("AuthToken","$ContactReq/Body/AuthToken","$ContactReq");
        this.fsidExpr_=W("$AuthToken/Value");
        this.groupsDataPath_="$Groups";
        this.groupsExpr_=W(this.groupsDataPath_);
        e.addListener(T(this.gotGroups_,this),this.groupsDataPath_);
        this.updateRoot_=c
    }
    ;
    U(up,wk);
    Q=up[y];
    Q.addAllContacts_=function(a,b){
        if(b==this.primaryDataListenPath_){
            Uf.info("Starting contact add");
            var c=W(a+"/*");
            c=c.getNodes();
            for(var e=c.getCount(),f=0;
            f<e;
            f++){
                var g=c.getByIndex(f);
                this.addContact(g)
            }
            this.contactsAfterLoad_&&this.parseContacts(this.contactsAfterLoad_,"^Temp");
            Uf.info("About to fire data change");
            V().fireDataChange("$Contacts");
            Uf.info("Ended contact add")
        }
    }
    ;
    Q.gotGroups_=function(){
        this.groupMap_={
        }
        ;
        for(var a=this.groupsExpr_.getNode().getChildNodes(),b=0;
        b<a.getCount();
        b++){
            var c=a.getByIndex(b);
            this.groupMap_[c.getChildNodeValue("id")]=c
        }
        this.linkGroups_()
    }
    ;
    Q.getChildNodes=function(a){
        if(!a||a=="*")return this.contactNodes_;
        else if(a[E]("*")==-1)return(a=this.getChildNode(a))?new Sf([a]):new Rf;
        else d(l("Selector not supported yet ("+a+")"))
    }
    ;
    Q.getChildNodeValue=function(a){
        a=this.contactNodes_.get(a);
        return a==j?j:a.get()
    }
    ;
    Q.addContact=function(a){
        var b=a.getEmail();
        a.root_.id=b;
        a.setDataName(b);
        this.contactNodes_.add(a);
        a.parent_=this;
        V().fireDataChange(a.getDataPath());
        return a
    }
    ;
    Q.updateContact=function(a,b){
        var c=j,e=a.getEmail();
        a.getChildNode("id").set(e);
        a.setDataName(e);
        for(var f=this.contactNodes_.list_,g=k,h=0;
        h<f[x];
        h++)if(f[h].getEmail()==e){
            a.getChildNode("SelectedCount").set(f[h].getChildNodeValue("SelectedCount"));
            if(sp(f[h],"^Temp")){
                g=a;
                c="^Temp";
                if(!sp(g,c)){
                    g=g.getChildNode("Groups");
                    g.get()||g.set([]);
                    g.getChildNode(c).set({
id:c
                    }
                    )
                }
            }
            f[h]=a;
            c=f[h];
            g=i
        }
        if(g){
            this.contactNodes_.map_.set(e,a);
            this.linkGroupsToContact_(a);
            a.parent_=this;
            V().fireDataChange(a.getDataPath());
            return c
        }
        else if(b)return this.addContact(a)
    }
    ;
    Q.parseContacts=function(a,b){
        for(var c=a[Fb](/[;
        ,]/),e=0;
        e<c[x];
        e++){
            var f=c[e],g=j,h=j;
            g=f[E]("<");
            if(g==-1)g=je(f);
            else{
                h=je(f[Sc](0,g));
                g=je(f[Sc](g+1,f[E](">",g)))
            }
            if(g[x]>0){
                if(this.contactNodes_.get(g))f=this.contactNodes_.get(g);
                else{
                    f={
Name:h,Email:g,id:g
                    }
                    ;
                    f=new wk(f,f.Email);
                    this.addContact(f)
                }
                f.getChildNode("SelectedCount").set(this.selectionCount_++);
                if(b){
                    f.getChildNode("Groups");
                    f=f.getChildNode("Groups");
                    f.get()||f.set([]);
                    f.getChildNode(b).set(b)
                }
            }
        }
        if(this.argz_){
            this.formatContacts(-1,"");
            this.parseContactsAfterLoad("")
        }
    }
    ;
    Q.parseContactsAfterLoad=function(a){
        this.contactsAfterLoad_=a
    }
    ;
    Q.formatContacts=function(a,b){
        for(var c=this.contactNodes_.getCount(),e=k,f="",g=0;
        g<c;
        g++){
            var h=this.contactNodes_.getByIndex(g);
            if(sp(h,a))if(h=h.getAsEmailString(b=="FULL",k)){
                if(e)f+=", ";
                f+=h;
                e=i
            }
        }
        return f
    }
    ;
    Q.getSelectionOrderedDs=function(){
        this.selectionOrderedNodes_=new Sf;
        var a,b=this.contactNodes_.getCount(),c=[],e=[];
        for(a=0;
        a<b;
        a++){
            var f=this.contactNodes_.getByIndex(a),g=f.getChildNodeValue("SelectedCount");
            if(g!=j)c[fa(g)]=f;
            else e[w](f)
        }
        b=c[x];
        for(a=0;
        a<b;
        a++)c[a]&&this.selectionOrderedNodes_.add(c[a]);
        return this.selectionOrderedNodes_
    }
    ;
    Q.createTempContact=function(a){
        a=a?Vd(W(a).getNode().root_):{
Groups:[]
        }
        ;
        a=new wk(a,"$TempContact");
        var b=V();
        b.addDataSource(a);
        b.fireDataChange("$TempContact");
        return a
    }
    ;
    Q.linkGroups_=function(){
        for(var a=this.contactNodes_.getCount(),b=0;
        b<a;
        b++){
            var c=this.contactNodes_.getByIndex(b);
            this.linkGroupsToContact_(c)
        }
    }
    ;
    Q.linkGroupsToContact_=function(a){
        a.getChildNode("Groups").get()==j&&a.getChildNode("Groups").set([]);
        a=a.getChildNode("Groups").getChildNodes();
        for(var b=0;
        b<a.getCount();
        b++){
            var c=a.getByIndex(b);
            if(c.get()&&c.getChildNodes().getCount()>0){
                var e=this.groupMap_[c.getChildNodeValue("id")];
                if(e){
                    var f=c.childNodeList_.get("ref");
                    f||c.childNodeList_.add(Vf(e,"ref"))
                }
            }
        }
    }
    ;
    var xp=function(a){
        this.contactDs_=a;
        wk[J](this,j,"SelectedContacts")
    }
    ;
    U(xp,wk);
    xp[y].getChildNodes=function(a){
        if(!a||a=="*")return this.contactDs_.getSelectionOrderedDs();
        else if(a[E]("*")==-1)return(a=this.getChildNode(a))?new Sf([a]):new Rf;
        else d(l("Selector not supported yet ("+a+")"))
    }
    ;
    var To=function(a,b,c){
        wk[J](this,j,a);
        this.name_=a;
        this.primaryDataPath_=b;
        this.primaryDataListenPath_=c;
        this.childNodes_=new Sf;
        this.root_=[];
        this.loaded_=k;
        a=V();
        a.addDataSource(this);
        a.addListener(T(this.gotData,this),c)
    }
    ;
    U(To,wk);
    To[y].gotData=function(){
        if(!this.loaded_){
            var a=this.primaryDataPath_;
            a=W(a+"/*");
            this.childNodes_=a.getNodes();
            for(a=0;
            a<this.childNodes_.getCount();
            a++)this.root_[w](this.childNodes_.getByIndex(a));
            V().fireDataChange("$"+this.name_);
            this.loaded_=i
        }
    }
    ;
    To[y].getChildNodes=function(a){
        if(!a||a=="*")return this.childNodes_;
        else d(l("Selector not supported yet ("+a+")"))
    }
    ;
    var yp=function(a,b,c){
        this.contactData_=a||Lm();
        this.successCallback_=b;
        this.failCallback_=c
    }
    ,zp=0;
    Q=yp[y];
    Q.getBaseRequestUri=function(a,b,c){
        c=c||this.contactData_.getServerPath();
        a=new Sh(c+"/"+b+"/"+a);
        b=this.contactData_.tokenExpr_.getNode().get();
        a.setParameterValue("token",b);
        a.setParameterValue("tok",b);
        a.setParameterValue("out","js");
        return a
    }
    ;
    Q.getBaseUpdateUri=function(a){
        return this.getBaseRequestUri(a,"update")
    }
    ;
    Q.getBaseDataUri=function(a){
        return this.getBaseRequestUri(a,"data")
    }
    ;
    Q.getUri=function(){
        d(l("getUri not implemented in "+this))
    }
    ;
    Ha(Q,function(){
        if(this.validate_&&!this.validate_())this.failCallback_&&this.failCallback_();
        else{
            $[u]("$ContactData/PendingRequest",i);
            var a=zp++;
            this.requestName_="ContactUpdate"+a;
            this.requestPath_="$ContactUpdate"+a;
            a=this.getUri();
            a=new ji(a,this.requestName_,"&&&START&&&","&&&END&&&",i);
            this.receiveFn_=T(this.receive_,this);
            var b=V();
            b.addDataSource(a,this.requestName_);
            b.addListener(this.receiveFn_,this.requestPath_);
            a[Eb]();
            this.received_=k;
            S[yb](T(this.showLongSpinner_,this),1E3)
        }
    }
    );
    Q.showLongSpinner_=function(){
        this.received_||$[u]("$ContactData/PendingLongRequest",i)
    }
    ;
    Q.receive_=function(){
        this.received_=i;
        $[u]("$ContactData/PendingRequest",k);
        $[u]("$ContactData/PendingLongRequest",k);
        var a=W(this.requestPath_+"/Success");
        if(a.getValue()){
            var b;
            if(this.onReceive_)b=this.onReceive_();
            this.successCallback_&&this.successCallback_(b);
            a=W(this.requestPath_+"/Messages/*");
            if(a.getNodes().getCount()>0){
                a=W(this.requestPath_+"/Messages/[0]/Text").getValue();
                Sl().add(a,"INFO")
            }
        }
        else if(a=W(this.requestPath_+"/TryLogin").getValue())ja("You have been logged out of your Google account. Please log back in to access contact data.");
        else{
            a=W(this.requestPath_+"/Errors/*");
            if(a.getNodes().getCount()>0){
                var c=W(this.requestPath_+"/Errors/[0]/Message").getValue(),e=W(this.requestPath_+"/Errors/[0]/Text").getValue();
                a=W(this.requestPath_+"/Errors/[0]/Source/LearnMoreUrl").getValue();
                b=W(this.requestPath_+"/Errors/[0]/Source/LearnMoreText").getValue();
                c=c||e;
                c="Error saving data: "+c;
                Sl().add(c,"ERROR",a,b)
            }
            else Sl().add("Unknown error saving data.","ERROR");
            this.failCallback_&&this.failCallback_()
        }
    }
    ;
    Q.addForwardingPhonesToUri=function(a,b,c){
        b=W(b).getNodes();
        b=b.getCount();
        for(var e=0,f=0;
        f<b;
        f++){
            var g=zi("ForwardingCheckbox-["+f+"]");
            if(g!=j){
                var h=g[D];
                if(g[wb]){
                    g=c[B]("/",".")+"."+m(e);
                    a.setParameterValue(g,h);
                    e++
                }
            }
        }
    }
    ;
    var Xo=function(a,b,c,e){
        this.contact_=b;
        yp[J](this,a,c,e);
        this.isAdd_=!b.getChildNodeValue("Id")
    }
    ;
    U(Xo,yp);
    Q=Xo[y];
    Q.getUri=function(){
        var a=this.contact_,b=this.getBaseUpdateUri("contact");
        if(a=a.getChildNodeValue("Id")){
            b.setParameterValue("id",a);
            b.setParameterValue("action","SET")
        }
        else b.setParameterValue("action","ADD");
        this.addContactInfo(b);
        return b
    }
    ;
    Q.addContactInfo=function(a){
        for(var b=this.contact_,c=W("Addresses/*").getNodes(b),e=0;
        e<c.getCount();
        e++){
            var f=c.getByIndex(e),g=f.getChildNodeValue("Source");
            if(!g){
                g="UNSTRUCTURED";
                f.setChildNode("Source",g)
            }
        }
        this.addFieldsToUri(a,b,wo);
        this.addFieldsToUri(a,b,yo,j);
        for(var h in Ao)this.addRepeatedFieldsToUri(a,b,h,Ao[h]);
        this.addRepeatedFieldsToUri(a,b,"Groups",["id","value"]);
        if(c=$[C]("$UserData/IsGcUser")){
            this.addFieldsToUri(a,b,["CallSettings/GreetingId","CallSettings/RingshareId","CallSettings/GroupId",
            "CallSettings/AlwaysScreen","CallSettings/Response","CallSettings/Mode","CallSettings/DirectConnect"]);
            this.addForwardingPhonesToUri(a,"$UserProfile/GcProfile/ForwardingPhones/*","CallSettings/ForwardingPhones")
        }
        return a
    }
    ;
    Q.addFieldsToUri=function(a,b,c,e){
        e=e||"";
        this.cleanFieldNode(b);
        for(var f=0;
        f<c[x];
        f++){
            var g=c[f],h=W(g).getValue(b);
            if(h){
                if(Od(h))h=je(h)
            }
            else h="";
            a.setParameterValue((e+g)[B]("/","."),h)
        }
    }
    ;
    Q.cleanFieldNode=function(a){
        if(a.Type&&a.Type.Id!="CUSTOM")a.Type.Label=j
    }
    ;
    Q.addRepeatedFieldsToUri=function(a,b,c,e){
        if(b=W(c).getNode(b))for(var f=0;
        f<b.getChildNodes().getCount();
        f++){
            var g=b.getChildNodes().getByIndex(f);
            this.addFieldsToUri(a,g,e,c+"."+m(f)+".")
        }
    }
    ;
    Q.validate_=function(){
        var a=i;
        if(this.contact_.isEmpty()){
            Sl().add("Cannot create an empty contact.","ERROR");
            a=k
        }
        if(this.contact_.hasAnyDateWithWrongDayRange()){
            Sl().add("Please enter only valid dates.","ERROR");
            a=k
        }
        if(this.contact_.hasBirthdayWithWrongDayRange()){
            Sl().add("Please enter a valid birthday.","ERROR");
            a=k
        }
        if(this.contact_.hasIncompleteDates()){
            Sl().add("Please enter a month, day and year for dates.","ERROR");
            a=k
        }
        if(Fo(this.contact_.getChildNode("Birthday"))&&!this.contact_.hasValidBirthday()){
            Sl().add("Please enter at least a month and day for birthday.",
            "ERROR");
            a=k
        }
        return a
    }
    ;
    Q.onReceive_=function(){
        var a=W(this.requestPath_+"/Body/Groups/*").getNodes();
        if(a.getCount()>0){
            a=new To("Groups",this.requestPath_+"/Body/Groups",this.requestPath_+"/Body/Groups");
            a.gotData()
        }
        a=W(this.requestPath_+"/Body/Contact").getNode();
        a=this.contactData_.updateContact(a);
        this.contactData_.notifyContactChanged_(a);
        this.isAdd_&&V().fireDataChange("$Contacts");
        return a
    }
    ;
    var Wo=function(a,b,c,e){
        Xo[J](this,a,b,c,e);
        this.ids_=b.mergeIds_
    }
    ;
    U(Wo,Xo);
    Wo[y].getUri=function(){
        var a=this.getBaseUpdateUri("contact");
        a.setParameterValues("ids",this.ids_);
        a.setParameterValue("action","MERGE");
        this.addContactInfo(a);
        return a
    }
    ;
    Wo[y].onReceive_=function(){
        for(var a=W(this.requestPath_+"/Body/Removed/*").getNodes(),b=[],c=0;
        c<a.getCount();
        c++){
            var e=a.getByIndex(c);
            e=e.getChildNodeValue("Id");
            b[w](e);
            this.contactData_.contactDeleted_(e)
        }
        V().fireDataChange("$Contacts");
        e=W(this.requestPath_+"/Body/Contact").getNode();
        a=(new vo(e)).getEmails()[ud](",");
        Sk()[Oc]("CONTACT_MERGED","id",e.getChildNodeValue("Id"),"removed",b,"emails",a);
        return Wo.superClass_.onReceive_[J](this)
    }
    ;
    var Ap=function(a,b,c,e){
        yp[J](this,a,c,e);
        this.contact_=b
    }
    ;
    U(Ap,yp);
    Ap[y].getUri=function(){
        var a=this.contactData_.getFfeServerPath();
        a=this.getBaseRequestUri("dcprofile","data",a);
        return this.addContactInfo(a)
    }
    ;
    Ap[y].addContactInfo=function(a){
        a.setParameterValue("id",this.contact_.getId());
        return a
    }
    ;
    Ap[y].validate_=function(){
        return this.contact_&&this.contact_.getId&&this.contact_.getId()
    }
    ;
    Ap[y].onReceive_=function(){
        var a=W(this.requestPath_+"/Body/Contact").getNode();
        if(a){
            a=this.contactData_.updateContact(a);
            a.setIsProfileLoaded(i);
            this.contactData_.notifyContactChanged_(a);
            return a
        }
        else{
            this.contact_.setIsProfileLoaded(i);
            return this.contact_
        }
    }
    ;
    var Bp=function(a,b,c,e){
        Ap[J](this,a,b,c,e)
    }
    ;
    U(Bp,Ap);
    Bp[y].addContactInfo=function(a){
        a.setParameterValues("email",this.contact_.getEmails());
        return a
    }
    ;
    Bp[y].onReceive_=function(){
        var a=W(this.requestPath_+"/Body/Contacts").getNodes(),b=[];
        if(a)for(var c=0;
        c<a.getCount();
        c++){
            var e=this.contactData_.updateContact(a.getByIndex(c));
            e.setIsProfileLoaded(i);
            b[w](e)
        }
        return b
    }
    ;
    Bp[y].validate_=function(){
        return this.contact_&&this.contact_.getEmail&&this.contact_.getEmail()
    }
    ;
    var Yo=function(a,b,c,e){
        yp[J](this,a,c,e);
        this.ids_=Od(b)?[b]:b
    }
    ;
    U(Yo,yp);
    Yo[y].getUri=function(){
        var a=this.getBaseUpdateUri("contact");
        a.setParameterValues("ids",this.ids_);
        a.setParameterValue("action","DELETE");
        return a
    }
    ;
    Yo[y].onReceive_=function(){
        for(var a=W(this.requestPath_+"/Body/Removed/*").getNodes(),b=0;
        b<a.getCount();
        b++){
            var c=a.getByIndex(b);
            this.contactData_.contactDeleted_(c.getChildNodeValue("Id"))
        }
        V().fireDataChange("$Contacts");
        a=new To("Groups",this.requestPath_+"/Body/Groups",this.requestPath_+"/Body/Groups");
        a.gotData();
        Sl().add("Contact has been deleted.","INFO");
        this.contactData_.notifyContactChanged_()
    }
    ;
    var bp=function(a,b,c,e,f,g){
        this.action_=c||"ADD";
        this.newName_=e;
        this.groupId_=b;
        yp[J](this,a,f,g)
    }
    ;
    U(bp,yp);
    bp[y].getSaveGroupUri=function(a,b){
        var c=this.getBaseUpdateUri("groups");
        c.setParameterValue("action",this.action_);
        this.groupId_&&c.setParameterValue("id",this.groupId_);
        this.newName_!=j&&c.setParameterValue("name",this.newName_);
        a[x]>0&&c.setParameterValues("contactIds",a);
        b[x]>0&&c.setParameterValues("newContacts",b);
        return c
    }
    ;
    var Cp=/^[0-9A-fa-f]+$/;
    bp[y].getUri=function(){
        var a=W("$Contacts/*").getNodes(),b=a.getCount(),c=[],e=[];
        this.bogusContacts_={
        }
        ;
        for(var f=0;
        f<b;
        f++){
            var g=a.getByIndex(f);
            if(this.contactData_.isContactInGroup(g,"^Temp")){
                var h=g.getChildNodeValue("Id");
                if(h&&h[nc](Cp))c[w](h);
                else{
                    var n=g.getEmail();
                    if(n){
                        g=g.getName()||"";
                        e[w](n+":"+g);
                        if(h)this.bogusContacts_[n]=h
                    }
                }
            }
        }
        a=this.getSaveGroupUri(c,e);
        if(b=$[C]("$UserData/IsGcUser")){
            this.addForwardingPhonesToUri(a,"$UserProfile/GcProfile/ForwardingPhones/*","CallSettings/ForwardingPhones");
            a.setParameterValue("CallSettings.GreetingId",$[C]("$TempGroup/CallSettings/GreetingId"));
            a.setParameterValue("CallSettings.DirectConnect",$[C]("$TempGroup/CallSettings/DirectConnect"))
        }
        return a
    }
    ;
    bp[y].onReceive_=function(){
        for(var a=W(this.requestPath_+"/Body/Contacts/*").getNodes(),b=0;
        b<a.getCount();
        b++){
            var c=a.getByIndex(b),e=k;
            if(this.bogusContacts_){
                var f=c.Emails||{
                }
                ;
                f=f[0]||{
                }
                ;
                var g=f.Address;
                if(g)if(f=this.bogusContacts_[g]){
                    delete this.bogusContacts_[g];
                    if(g=this.contactData_.getContact(f)){
                        e=g.isInGroup("^Temp");
                        this.contactData_.contactDeleted_(f)
                    }
                }
            }
            c=this.contactData_.updateContact(c);
            e&&this.contactData_.selectContact(c,i)
        }
        V().fireDataChange("$Contacts");
        this.contactData_.newGroupData(this.requestPath_);
        V().fireDataChange("$Groups");
        this.contactData_.notifyGroupChanged_()
    }
    ;
    var Dp=function(a,b,c,e,f,g,h){
        bp[J](this,a,c,e,f,g,h);
        this.contactIds_=b
    }
    ;
    U(Dp,bp);
    Dp[y].getUri=function(){
        return this.getSaveGroupUri(this.contactIds_,[])
    }
    ;
    var Ep=function(a,b,c){
        yp[J](this,a,b,c)
    }
    ;
    U(Ep,yp);
    var Fp=new qf({
MineAutoAdd:"maa"
    }
    );
    Ep[y].getUri=function(){
        for(var a=this.getBaseUpdateUri("prefs"),b=Fp.getKeys(),c=0;
        c<b[x];
        c++){
            var e=W("$UserPrefs/"+b[c]).getNode();
            if(e){
                e=e.get();
                var f=Fp.get(b[c]);
                a.setParameterValue(f,e)
            }
        }
        return a
    }
    ;
    var $o=function(a,b,c,e){
        yp[J](this,a,c,e);
        this.ids_=Od(b)?[b]:b
    }
    ;
    U($o,yp);
    $o[y].getUri=function(){
        var a=this.getBaseUpdateUri("merge");
        a.setParameterValues("ids",this.ids_);
        a.setParameterValue("action","PREVIEW");
        return a
    }
    ;
    $o[y].onReceive_=function(){
        for(var a=[],b=0;
        b<this.ids_[x];
        b++){
            var c=this.contactData_.getContact(this.ids_[b]);
            a[w](c.getNameForDisplay())
        }
        b=this.contactData_.createTempContact(this.requestPath_+"/Body/Contact");
        b.add(hi(a,"MergeSnippets"));
        b.mergeIds_=this.ids_;
        return b
    }
    ;
    var Zo=function(a,b,c,e){
        yp[J](this,a,c,e);
        this.ids_=Od(b)?[b]:b
    }
    ;
    U(Zo,yp);
    Zo[y].getUri=function(){
        var a=this.getBaseUpdateUri("contact");
        a.setParameterValues("ids",this.ids_);
        a.setParameterValue("action","IGNORE");
        return a
    }
    ;
    Zo[y].onReceive_=function(){
        var a=$.getNodes(this.requestPath_+"/Body/Groups/*");
        if(a.getCount()>0){
            a=new To("Groups",this.requestPath_+"/Body/Groups",this.requestPath_+"/Body/Groups");
            a.gotData()
        }
        a=W(this.requestPath_+"/Body/Contacts/*").getNodes();
        for(var b=0;
        b<a.getCount();
        b++){
            var c=a.getByIndex(b);
            c=this.contactData_.getContact(c.Id);
            this.contactData_.selectContact(c,k);
            c.setNeverSuggest(i)
        }
        V().fireDataChange("$Contacts")
    }
    ;
    var Gp=function(a,b,c){
        yp[J](this,a,b,c)
    }
    ;
    U(Gp,yp);
    Gp[y].getUri=function(){
        return this.getBaseDataUri("detectduplicates")
    }
    ;
    Gp[y].onReceive_=function(){
        var a=$.getNodes(this.requestPath_+"/Body/*"),b=a.get("Duplicates");
        if(b)for(var c=0;
        c<b.getCount();
        c++){
            var e=b.getByIndex(c);
            e.setNode("MergedContact",new vo(e.get("MergedContact").getJsObject()))
        }
        a=new ei(a,"$DuplicateDetectionResult");
        V().addDataSource(a,j,"$DuplicateDetectionResult")
    }
    ;
    var Hp=function(a,b,c,e){
        yp[J](this,a,c,e);
        this.duplicateSets_=b;
        this.refreshTimeout_=100
    }
    ;
    U(Hp,yp);
    Hp[y].getUri=function(){
        var a=this.getBaseUpdateUri("mergeduplicates");
        a.setParameterValues("toMerge",this.duplicateSets_);
        return a
    }
    ;
    Hp[y].onReceive_=function(){
        S[yb](function(){
            Lm()[Eb](2);
            var a=new Ig("RELOAD_CONTACTS");
            Uk().doEvent(a)
        }
        ,this.refreshTimeout_)
    }
    ;
    var Ip=function(a,b,c){
        this.dataPath_=b;
        this.rows_=[];
        this.rowMap_={
        }
        ;
        this.rowEls_=[];
        this.config_=c||{
        }
        ;
        this.nodeName_=this.getConfig("ELEMENT_NAME","div");
        this.parentNodeName_=this.getConfig("ROOT_ELEMENT_NAME","div");
        this.rootEl_=a[v](Ki(this.parentNodeName_));
        this.selectOnMouseDown_=this.getConfig("SELECT_ON_MOUSE_DOWN",k);
        this.fixedRowHeight_=this.getConfig("FIXED_HEIGHT",k);
        this.manualRowSet_=this.getConfig("MANUAL_ROWSET",k);
        this.rowsExpr_=W(this.dataPath_+"/*");
        this.hasInvalidRows_=k;
        this.invalidRows_=
        {
        }
        ;
        this.invalidDataRows_={
        }
        ;
        this.shiftSelectAnchor_=-1;
        if(!this.manualRowSet_){
            this.rowsChangeListener_=T(this.rowsChanged_,this);
            V().addListener(this.rowsChangeListener_,b)
        }
        this.rowChangeListener_=T(this.rowChanged_,this);
        V().addIndexedListener(this.rowChangeListener_,this.dataPath_+"/*/...");
        Y(a,"click",this.handleClick_,i,this);
        Y(a,"mouseover",this.handleMouseOver_,k,this);
        Y(a,"mouseout",this.handleMouseOut_,k,this);
        Y(a,"mousedown",this.handleMouseDown_,k,this)
    }
    ;
    mf(Ip[y],uh[y]);
    Q=Ip[y];
    Q.getConfig=function(a,b){
        var c=this.config_[a];
        return c!=j?c:b
    }
    ;
    Q.render=function(){
        this.increment_=25;
        this.renderChildren_(this.rootEl_);
        this.markValid_()
    }
    ;
    Q.invalidate=function(){
        if(!this.invalid_){
            this.invalid_=i;
            S[yb](T(this.baseRender_,this),5)
        }
    }
    ;
    Q.baseRender_=function(){
        if(this.invalid_){
            this.render();
            this.invalid_=k;
            this[F](new Ig("LIST_CHANGED"))
        }
    }
    ;
    Q.invalidateVisibility_=function(){
        if(this.inDraw_)this.invalidate();
        else if(this.rows_[x]>0){
            for(var a=0,b=0;
            b<this.rows_[x];
            b++){
                var c=this.rows_[b],e=this.rowEls_[b];
                if(e){
                    c=this.shouldRenderRow(c);
                    e=e.rendered_;
                    if(c&&!e||!c&&e){
                        this.hasInvalidRows_=i;
                        this.invalidRows_[b]=i;
                        a++
                    }
                }
            }
            if(this.hasInvalidRows_)if(a>100){
                this.hasInvalidRows_=k;
                this.invalidate()
            }
            else S[yb](T(this.renderInvalidRows_,this),0)
        }
    }
    ;
    Q.renderChildren_=function(a){
        Qi(a);
        this.currentSectionHeaderIndex_=0;
        this.getRowsForRendering_();
        (a=this.createSectionHeaders_(this.rows_))&&this.setSectionHeaders(a);
        this.computeHeightsAndRender_()
    }
    ;
    Q.getRowsForRendering_=function(){
        if(!this.manualRowSet_){
            var a=this.rowsExpr_.getNodes();
            pa(this.rows_,0);
            for(var b=a.getCount(),c=0;
            c<b;
            c++){
                var e=a.getByIndex(c);
                this.rows_[w](e)
            }
        }
    }
    ;
    Q.computeHeightsAndRender_=function(){
        this.inDraw_=i;
        this.activeRow_=-1;
        this.incrementalDrawIndex_=0;
        pa(this.rowEls_,0);
        for(var a=this.rows_[x],b=0;
        b<a;
        b++)this.rowMap_[this.rows_[b].getDataName()]=b;
        if(this.fixedRowHeight_&&a>this.increment_){
            this.increment_=1;
            this.renderOneIncrementOfRows_();
            var c=Mj(this.rootEl_);
            this.renderOneIncrementOfRows_();
            b=Mj(this.rootEl_);
            c=b[P]-c[P];
            a=a-2;
            Xa(this.rootEl_[H],b[P]+a*c);
            if(a=Mj(this.rootEl_[O]))if(a[P]>0&&c>0)this.lastIncrement_=this.increment_=a[P]/c;
            else this.increment_=
            this.lastIncrement_
        }
        this.renderSomeRows_()
    }
    ;
    Q.scrollToFirstMatchingRow=function(a){
        if(a.getCount()!=0)for(var b=0;
        b<this.rows_[x];
        b++){
            var c=this.rows_[b].getId();
            if(a.get(c)){
                a=this.rootEl_[O][O];
                a.scrollTop=this.rowEls_[b][nd];
                break
            }
        }
    }
    ;
    Q.createSectionHeaders_=function(){
        return j
    }
    ;
    Q.dispose=function(){
        if(!this.disposed_){
            this.disposed_=i;
            var a=V();
            a.removeListeners(this.rowChangeListener_);
            a.removeListeners(this.rowsChangeListener_)
        }
    }
    ;
    Q.renderSomeRows_=function(){
        if(!this.inDraw_||this.disposed_)this[F](new Ig("LIST_RENDERED"));
        else{
            this.renderOneIncrementOfRows_();
            if(this.incrementalDrawIndex_<this.rows_[x])S[yb](T(this.renderSomeRows_,this),this.rowTimeout_);
            else{
                this.renderHeaders_(-1);
                Xa(this.rootEl_[H],"");
                this.inDraw_=k;
                this[F](new Ig("LIST_RENDERED"))
            }
        }
    }
    ;
    Q.renderOneIncrementOfRows_=function(){
        for(var a=this.rows_[x],b=0;
        this.incrementalDrawIndex_<a&&b<this.increment_;
        ){
            this.renderHeaders_(this.incrementalDrawIndex_);
            var c=this.rows_[this.incrementalDrawIndex_],e=Ki(this.nodeName_,{
className:"row"
            }
            );
            e.listIndex_=this.incrementalDrawIndex_;
            this.possiblyRenderRow_(c,e)&&b++;
            this.rootEl_[v](e);
            this.rowEls_[w](e);
            this.incrementalDrawIndex_++
        }
    }
    ;
    Q.possiblyRenderRow_=function(a,b){
        if(b)if(this.shouldRenderRow(a)){
            Wa(b[H],"");
            b.rendered_=i;
            this.renderRow(a,b);
            return i
        }
        else{
            if(b[H][ld]!="none"){
                xj(b,"display","none");
                b.rendered_=k
            }
            return k
        }
    }
    ;
    Q.renderRow=function(){
    }
    ;
    Q.rowsChanged_=function(a){
        a==this.dataPath_&&this.invalidate()
    }
    ;
    Q.setRows=function(a){
        this.rows_=a;
        this.invalidate()
    }
    ;
    Q.rowChanged_=function(a,b,c){
        if(this.rows_[x]>0){
            a=this.hasInvalidRows_;
            this.hasInvalidRows_=i;
            if(b)this.invalidRows_[b]=i;
            if(c)this.invalidDataRows_[c[0]]=i;
            a||S[yb](T(this.renderInvalidRows_,this),0)
        }
    }
    ;
    Q.renderInvalidRows_=function(){
        if(this.hasInvalidRows_){
            for(var a in this.invalidDataRows_){
                var b=this.rowMap_[a];
                if(b!=j){
                    var c=this.rows_[b];
                    if(c){
                        c=W(c.getDataPath()).getNode();
                        this.rows_[b]=c;
                        this.invalidRows_[b]=i
                    }
                }
            }
            for(var e in this.invalidRows_)this.rows_[e]&&this.possiblyRenderRow_(this.rows_[e],this.rowEls_[e]);
            this.markValid_()
        }
    }
    ;
    Q.markValid_=function(){
        this.hasInvalidRows_&&this[F](new Ig("LIST_CHANGED"));
        this.hasInvalidRows_=k;
        this.invalidRows_={
        }
        ;
        this.invalidDataRows_={
        }
    }
    ;
    Q.getIndexOfRow=function(a){
        return a==j||a[zb]==9?-1:Qe(ti(a),"row")?a.listIndex_:this.getIndexOfRow(a[O])
    }
    ;
    Q.setActiveRow_=function(a){
        if(a!=this.activeRow_){
            this.activeRow_!=-1&&vi(this.rowEls_[this.activeRow_],"active");
            ui(this.rowEls_[a],"active");
            this.activeRow_=a
        }
    }
    ;
    Q.deactivateRow_=function(a){
        if(!a||a==this.activeRow_){
            vi(this.rowEls_[this.activeRow_],"active");
            this.activeRow_=-1
        }
    }
    ;
    Q.incActiveRow=function(){
        for(var a=this.activeRow_+1;
        a<this.rows_[x];
        a++){
            var b=this.rows_[a];
            if(this.shouldRenderRow(b)){
                this.setActiveRow_(a);
                break
            }
        }
    }
    ;
    Q.decActiveRow=function(){
        for(var a=this.activeRow_-1;
        a>0;
        a--){
            var b=this.rows_[a];
            if(this.shouldRenderRow(b)){
                this.setActiveRow_(a);
                break
            }
        }
    }
    ;
    Q.handleMouseOver_=function(a){
        a=this.getIndexOfRow(a[I]);
        a!=-1&&this.setActiveRow_(a)
    }
    ;
    Q.handleMouseOut_=function(a){
        a=this.getIndexOfRow(a[I]);
        a!=-1&&this.deactivateRow_(a);
        if(this.preselectedIndex_!=-1){
            vi(this.rowEls_[this.preselectedIndex_],"preselect");
            this.preselectedIndex_=-1
        }
    }
    ;
    Q.handleClick_=function(a){
        if(!this.selectOnMouseDown_){
            var b=this.getIndexOfRow(a[I]);
            b!=-1&&this.handleSelect_(a,b);
            if(this.preselectedIndex_!=-1){
                (b=this.rowEls_[this.preselectedIndex_])&&vi(b,"preselect");
                this.preselectedIndex_=-1
            }
        }
        a[Ob]()
    }
    ;
    Q.handleMouseDown_=function(a){
        var b=this.getIndexOfRow(a[I]);
        if(b!=-1)if(this.selectOnMouseDown_)this.handleSelect_(a,b);
        else{
            ui(this.rowEls_[b],"preselect");
            this.preselectedIndex_=b;
            vi(this.rowEls_[b],"active")
        }
        a[Sb]()
    }
    ;
    Q.handleSelect_=function(a,b,c){
        var e=a[cd];
        a=a[Db]||c;
        if(!e&&this.isInShiftSelectState_())this.shiftSelectAnchor_=-1;
        if(this.isInShiftSelectState_()){
            X&&kh(q[dc],"selectstart",function(){
                return k
            }
            ,k);
            this.changeMultipleRows_(this.shiftSelectAnchor_,b)
        }
        else this.selectRow(b,a);
        this.shiftSelectAnchor_=b
    }
    ;
    Q.changeMultipleRows_=function(a,b){
        var c=a,e=b,f=i;
        if(a>b){
            c=b;
            e=a;
            f=k
        }
        var g=[];
        for(c=c;
        c<=e;
        c++)g[w](this.rows_[c]);
        this[F](new Jp(g,f))
    }
    ;
    Q.isInShiftSelectState_=function(){
        return this.shiftSelectAnchor_!=-1
    }
    ;
    Q.shouldRenderRow=function(){
        return i
    }
    ;
    Q.selectRow=function(a,b){
        var c=this.rows_[a];
        vi(this.rowEls_[a],"preselect");
        var e=b!=j?b:k;
        this[F](new Kp(c,a,e))
    }
    ;
    Q.setSectionHeaders=function(a){
        this.sectionHeaders_=a
    }
    ;
    Q.renderHeaders_=function(a){
        if(this.sectionHeaders_)for(;
        this.sectionHeaders_[x]>this.currentSectionHeaderIndex_;
        ){
            var b=this.sectionHeaders_[this.currentSectionHeaderIndex_];
            if(b&&(a==-1||b.getStartIndex()<=a)){
                this.renderHeader_(b);
                this.currentSectionHeaderIndex_++
            }
            else break
        }
    }
    ;
    Q.renderHeader_=function(a){
        a=(a=a.getText())&&a[x]>0?Ki("div",{
className:"header"
        }
        ,q[Nb](a)):Ki("hr",{
className:"header"
        }
        );
        this.rootEl_[v](a)
    }
    ;
    Q.currentSectionHeaderIndex_=0;
    Q.incrementalDrawIndex_=0;
    Q.inDraw_=k;
    Q.increment_=25;
    Q.lastIncrement_=25;
    Q.rowTimeout_=20;
    Q.invalid_=k;
    Q.preselectedIndex_=-1;
    var Kp=function(a,b,c){
        Ig[J](this,"SELECT");
        this.row=a;
        this.index=b;
        this.additional=c
    }
    ;
    U(Kp,Ig);
    var Jp=function(a,b){
        Ig[J](this,"MULTI_SELECT");
        this.rowList=a;
        this.down=b
    }
    ;
    U(Jp,Ig);
    var Lp=function(a,b){
        this.text_=a;
        this.startIndex_=b
    }
    ;
    Lp[y].getText=function(){
        return this.text_
    }
    ;
    Lp[y].getStartIndex=function(){
        return this.startIndex_
    }
    ;
    var Mp=function(){
    }
    ;
    U(Mp,Cn);
    Kd(Mp);
    Q=Mp[y];
    Q.createDom=function(a){
        var b=this.getClassNames(a);
        b={
            "class":"goog-inline-block "+b[ud](" "),title:a.getTooltip()||""
        }
        ;
        return a.getDomHelper().createDom("div",b,a.getContent())
    }
    ;
    Q.getAriaRole=function(){
        return"button"
    }
    ;
    Q.canDecorate=function(a){
        return a[dd]=="DIV"
    }
    ;
    Q.decorate=function(a,b){
        ui(b,"goog-inline-block");
        return Mp.superClass_.decorate[J](this,a,b)
    }
    ;
    Q.getValue=function(){
        return j
    }
    ;
    Q.getCssClass=function(){
        return"goog-flat-button"
    }
    ;
    En("goog-flat-button",function(){
        return new Pn(j,Mp.getInstance())
    }
    );
    var Pp=function(){
        this.name_="closure_frame"+Np++;
        this.iframesForDisposal_=[];
        Op[this.name_]=this
    }
    ,Qp;
    U(Pp,uh);
    var Op={
    }
    ,Np=0,Rp=function(a,b){
        pf(b,function(c,e){
            var f=Ki("input",{
type:"hidden",name:e,value:c
            }
            );
            a[v](f)
        }
        )
    }
    ;
    Q=Pp[y];
    Q.logger_=Of("goog.net.IframeIo");
    Q.form_=j;
    Q.iframe_=j;
    Q.iframeName_=j;
    Q.nextIframeId_=0;
    Q.active_=k;
    Q.complete_=k;
    Q.success_=k;
    Q.lastUri_=j;
    Q.lastContent_=j;
    Q.lastErrorCode_=0;
    Q.timeoutInterval_=0;
    Q.timeoutId_=j;
    Q.firefoxSilentErrorTimeout_=j;
    Q.iframeDisposalTimer_=j;
    Ha(Q,function(a,b,c,e){
        if(this.active_)d(l("[goog.net.IframeIo] Unable to send, already active."));
        this.lastUri_=a=new Sh(a);
        b=b?b[qd]():"GET";
        c&&a.makeUnique();
        this.logger_.info("Sending iframe request: "+a+" ["+b+"]");
        if(!Qp){
            Qp=Ki("form");
            Qp.acceptCharset="utf-8";
            c=Qp[H];
            ra(c,"absolute");
            $a(c,"hidden");
            c.top=Da(c,"-10px");
            ta(c,Xa(c,"10px"));
            Va(c,"hidden");
            q[dc][v](Qp)
        }
        this.form_=c=Qp;
        b=="GET"&&Rp(this.form_,a.getQueryData());
        e&&Rp(this.form_,e);
        Na(this.form_,a[db]());
        this.form_.method=b;
        this.sendFormInternal_()
    }
    );
    Q.sendFromForm=function(a,b,c){
        if(this.active_)d(l("[goog.net.IframeIo] Unable to send, already active."));
        b=new Sh(b||a[Yc]);
        c&&b.makeUnique();
        this.logger_.info("Sending iframe request from form: "+b);
        this.lastUri_=b;
        this.form_=a;
        Na(this.form_,b[db]());
        this.sendFormInternal_()
    }
    ;
    Q.abort=function(a){
        if(this.active_){
            this.logger_.info("Request aborted");
            ph(this.getRequestIframe_());
            this.success_=this.active_=this.complete_=k;
            this.lastErrorCode_=a||7;
            this[F]("abort");
            this.makeReady_()
        }
    }
    ;
    Q.disposeInternal=function(){
        this.logger_.fine("Disposing iframeIo instance");
        if(this.active_){
            this.logger_.fine("Aborting active request");
            this[vb]()
        }
        Pp.superClass_.disposeInternal[J](this);
        this.iframe_&&this.scheduleIframeDisposal_();
        this.disposeForm_();
        delete this.errorChecker_;
        this.lastUri_=this.lastCustomError_=this.lastContent_=this.lastContentHtml_=this.form_=j;
        this.lastErrorCode_=0;
        delete Op[this.name_]
    }
    ;
    Q.isComplete=function(){
        return this.complete_
    }
    ;
    Q.isSuccess=function(){
        return this.success_
    }
    ;
    Q.isActive=function(){
        return this.active_
    }
    ;
    Q.getResponseText=function(){
        return this.lastContent_
    }
    ;
    Q.getResponseJson=function(){
        return vh(this.lastContent_)
    }
    ;
    Q.getResponseXml=function(){
        if(!this.iframe_)return j;
        return this.getContentDocument_()
    }
    ;
    Q.getLastUri=function(){
        return this.lastUri_
    }
    ;
    Q.getLastErrorCode=function(){
        return this.lastErrorCode_
    }
    ;
    Q.setTimeoutInterval=function(a){
        this.timeoutInterval_=r.max(0,a)
    }
    ;
    Ba(Q,function(a){
        this.iframe_&&Gh.pushContext(this.iframe_);
        try{
            return Pp.superClass_[F][J](this,a)
        }
        finally{
            this.iframe_&&Gh.popContext();
            return i
        }
    }
    );
    Q.sendFormInternal_=function(){
        this.active_=i;
        this.complete_=k;
        this.lastErrorCode_=0;
        this.createIframe_();
        if(X){
            Ea(this.form_,this.iframeName_||"");
            this.appendIframe_();
            Y(this.iframe_,"readystatechange",this.onIeReadyStateChange_,k,this);
            try{
                this.errorHandled_=k;
                this.form_.submit()
            }
            catch(a){
                lh(this.iframe_,"readystatechange",this.onIeReadyStateChange_,k,this);
                this.handleError_(1)
            }
        }
        else{
            this.logger_.fine("Setting up iframes and cloning form");
            this.appendIframe_();
            var b=this.iframeName_+"_inner",c=
            Vi(this.iframe_),e="<body><iframe id="+b+" name="+b+"></iframe>";
            if(lg)xa(c[Dd],e);
            else c.write(e);
            Y(c[Ib](b),"load",this.onIframeLoaded_,k,this);
            var f=this.form_[xd]("textarea");
            e=0;
            for(var g=f[x];
            e<g;
            e++)aj(f[e])!=f[e][D]&&Wi(f[e],f[e][D]);
            f=c.importNode(this.form_,i);
            Ea(f,b);
            c[dc][v](f);
            var h=this.form_[xd]("select"),n=f[xd]("select");
            e=0;
            for(g=h[x];
            e<g;
            e++)sa(n[e],h[e].selectedIndex);
            h=this.form_[xd]("input");
            n=f[xd]("input");
            e=0;
            for(g=h[x];
            e<g;
            e++)if(h[e][Zc]=="file")if(h[e][D]!=n[e][D]){
                this.logger_.fine("File input value not cloned properly.  Will submit using original form.");
                Ea(this.form_,b);
                f=this.form_;
                break
            }
            this.logger_.fine("Submitting form");
            try{
                this.errorHandled_=k;
                f.submit();
                c[ac]();
                if(mg)this.firefoxSilentErrorTimeout_=Dh(this.testForFirefoxSilentError_,250,this)
            }
            catch(o){
                this.logger_.severe("Error when submitting form: "+vf(o));
                lh(c[Ib](b),"load",this.onIframeLoaded_,k,this);
                c[ac]();
                this.handleError_(2)
            }
        }
    }
    ;
    Q.onIeReadyStateChange_=function(){
        if(this.iframe_[sc]=="complete"){
            lh(this.iframe_,"readystatechange",this.onIeReadyStateChange_,k,this);
            var a;
            try{
                a=Vi(this.iframe_);
                if(X&&a[Rb]=="about:blank"&&!navigator.onLine){
                    this.handleError_(9);
                    return
                }
            }
            catch(b){
                this.handleError_(1);
                return
            }
            this.handleLoad_(a)
        }
    }
    ;
    Q.onIframeLoaded_=function(){
        if(!(lg&&this.getContentDocument_()[Rb]=="about:blank")){
            lh(this.getRequestIframe_(),"load",this.onIframeLoaded_,k,this);
            this.handleLoad_(this.getContentDocument_())
        }
    }
    ;
    Q.handleLoad_=function(a){
        this.logger_.fine("Iframe loaded");
        this.complete_=i;
        this.active_=k;
        var b;
        try{
            var c=a[dc];
            this.lastContent_=c.textContent||c.innerText;
            this.lastContentHtml_=c.innerHTML
        }
        catch(e){
            b=1
        }
        var f;
        if(!b&&typeof this.errorChecker_=="function")if(f=this.errorChecker_(a))b=4;
        this.logger_.finer("Last content: "+this.lastContent_);
        this.logger_.finer("Last uri: "+this.lastUri_);
        if(b){
            this.logger_.fine("Load event occurred but failed");
            this.handleError_(b,f)
        }
        else{
            this.logger_.fine("Load succeeded");
            this.success_=i;
            this.lastErrorCode_=0;
            this[F]("complete");
            this[F]("success");
            this.makeReady_()
        }
    }
    ;
    Q.handleError_=function(a,b){
        if(!this.errorHandled_){
            this.active_=this.success_=k;
            this.complete_=i;
            this.lastErrorCode_=a;
            if(a==4)this.lastCustomError_=b;
            this[F]("complete");
            this[F]("error");
            this.makeReady_();
            this.errorHandled_=i
        }
    }
    ;
    Q.makeReady_=function(){
        this.logger_.info("Ready for new requests");
        var a=this.iframe_;
        this.scheduleIframeDisposal_();
        this.disposeForm_();
        Gh.pushContext(a);
        try{
            this[F]("ready")
        }
        finally{
            Gh.popContext()
        }
    }
    ;
    Q.createIframe_=function(){
        this.logger_.fine("Creating iframe");
        this.iframeName_=this.name_+"_"+(this.nextIframeId_++)[db](36);
        var a={
name:this.iframeName_,id:this.iframeName_
        }
        ;
        if(X&&Bg<7)a.src='javascript:""';
        this.iframe_=Ki("iframe",a);
        a=this.iframe_[H];
        $a(a,"hidden");
        ta(a,Xa(a,"10px"));
        if(ng)a.marginTop=a.marginLeft="-10px";
        else{
            ra(a,"absolute");
            a.top=Da(a,"-10px")
        }
    }
    ;
    Q.appendIframe_=function(){
        q[dc][v](this.iframe_)
    }
    ;
    Q.scheduleIframeDisposal_=function(){
        var a=this.iframe_;
        if(a){
            oa(a,j);
            a.onload=j;
            a.onerror=j;
            this.iframesForDisposal_[w](a)
        }
        if(this.iframeDisposalTimer_){
            Ah[qb](this.iframeDisposalTimer_);
            this.iframeDisposalTimer_=j
        }
        if(mg||lg)this.iframeDisposalTimer_=Dh(this.disposeIframes_,2E3,this);
        else this.disposeIframes_();
        this.iframeName_=this.iframe_=j
    }
    ;
    Q.disposeIframes_=function(){
        if(this.iframeDisposalTimer_){
            Ah[qb](this.iframeDisposalTimer_);
            this.iframeDisposalTimer_=j
        }
        for(var a=0;
        a<this.iframesForDisposal_[x];
        ){
            var b=this.iframesForDisposal_[a];
            if(Gh.isContextSafe(b)){
                this.logger_.info("Disposing iframe");
                Re(this.iframesForDisposal_,a);
                Ri(b)
            }
            else a++
        }
        if(this.iframesForDisposal_[x]!=0){
            this.logger_.info("Requests outstanding, waiting to dispose");
            this.iframeDisposalTimer_=Dh(this.disposeIframes_,2E3,this)
        }
    }
    ;
    Q.disposeForm_=function(){
        this.form_&&this.form_==Qp&&Qi(this.form_);
        this.form_=j
    }
    ;
    Q.getContentDocument_=function(){
        if(this.iframe_)return Vi(this.getRequestIframe_());
        return j
    }
    ;
    Q.getRequestIframe_=function(){
        if(this.iframe_)return X?this.iframe_:Vi(this.iframe_)[Ib](this.iframeName_+"_inner");
        return j
    }
    ;
    Q.testForFirefoxSilentError_=function(){
        if(this.active_){
            var a=this.getContentDocument_();
            if(a)try{
                a.closure_export_=a.documentUri
            }
            catch(b){
                lh(this.getRequestIframe_(),"load",this.onIframeLoaded_,k,this);
                if(navigator.onLine){
                    this.logger_.warning("Silent Firefox error detected");
                    this.handleError_(3)
                }
                else{
                    this.logger_.warning("Firefox is offline so report offline error instead of silent error");
                    this.handleError_(9)
                }
                return
            }
            this.firefoxSilentErrorTimeout_=Dh(this.testForFirefoxSilentError_,250,this)
        }
    }
    ;
    var Sp=function(a){
        Ig[J](this,"incrementaldata");
        this.data=a
    }
    ;
    U(Sp,Ig);
    var Tp=function(a,b,c,e){
        if(!Md(a)||!Md(b))d(l("Start and end parameters must be arrays"));
        if(a[x]!=b[x])d(l("Start and end points must be the same length"));
        this.startPoint=a;
        this.endPoint=b;
        this.duration=c;
        this.accel_=e;
        Ja(this,[])
    }
    ;
    U(Tp,uh);
    var Up={
    }
    ,Vp=j,Wp=function(){
        Ah[qb](Vp);
        var a=$d(),b;
        for(b in Up)Up[b].cycle(a);
        Vp=gf(Up)?j:Ah[yb](Wp,20)
    }
    ,Xp=function(a){
        a=Ud(a);
        delete Up[a];
        if(Vp&&gf(Up)){
            Ah[qb](Vp);
            Vp=j
        }
    }
    ;
    Q=Tp[y];
    Q.state_=0;
    Q.fps_=0;
    Q.progress=0;
    Q.startTime=j;
    Q.endTime=j;
    Q.lastFrame=j;
    Q.play=function(a){
        if(a||this.state_==0){
            this.progress=0;
            Ja(this,this.startPoint)
        }
        else if(this.state_==1)return k;
        Xp(this);
        this.startTime=$d();
        if(this.state_==-1)this.startTime-=this.duration*this.progress;
        this.endTime=this.startTime+this.duration;
        this.lastFrame=this.startTime;
        this.progress||this.onBegin();
        this.onPlay();
        this.state_==-1&&this.onResume();
        this.state_=1;
        a=Ud(this);
        a in Up||(Up[a]=this);
        Vp||(Vp=Ah[yb](Wp,20));
        this.cycle(this.startTime);
        return i
    }
    ;
    Q.stop=function(a){
        Xp(this);
        this.state_=0;
        if(a)this.progress=1;
        this.updateCoords_(this.progress);
        this.onStop();
        this.onEnd()
    }
    ;
    Q.pause=function(){
        if(this.state_==1){
            Xp(this);
            this.state_=-1;
            this.onPause()
        }
    }
    ;
    Q.disposeInternal=function(){
        this.state_!=0&&this[cb](k);
        this.onDestroy();
        Tp.superClass_.disposeInternal[J](this)
    }
    ;
    Q.cycle=function(a){
        this.progress=(a-this.startTime)/(this.endTime-this.startTime);
        if(this.progress>=1)this.progress=1;
        this.fps_=1E3/(a-this.lastFrame);
        this.lastFrame=a;
        Qd(this.accel_)?this.updateCoords_(this.accel_(this.progress)):this.updateCoords_(this.progress);
        if(this.progress==1){
            this.state_=0;
            Xp(this);
            this.onFinish();
            this.onEnd()
        }
        else this.state_==1&&this.onAnimate()
    }
    ;
    Q.updateCoords_=function(a){
        Ja(this,ma(this.startPoint[x]));
        for(var b=0;
        b<this.startPoint[x];
        b++)this[Bc][b]=(this.endPoint[b]-this.startPoint[b])*a+this.startPoint[b]
    }
    ;
    Q.onAnimate=function(){
        this.dispatchAnimationEvent_("animate")
    }
    ;
    Q.onBegin=function(){
        this.dispatchAnimationEvent_("begin")
    }
    ;
    Q.onDestroy=function(){
        this.dispatchAnimationEvent_("destroy")
    }
    ;
    Q.onEnd=function(){
        this.dispatchAnimationEvent_("end")
    }
    ;
    Q.onFinish=function(){
        this.dispatchAnimationEvent_("finish")
    }
    ;
    Q.onPause=function(){
        this.dispatchAnimationEvent_("pause")
    }
    ;
    Q.onPlay=function(){
        this.dispatchAnimationEvent_("play")
    }
    ;
    Q.onResume=function(){
        this.dispatchAnimationEvent_("resume")
    }
    ;
    Q.onStop=function(){
        this.dispatchAnimationEvent_("stop")
    }
    ;
    Q.dispatchAnimationEvent_=function(a){
        this[F](new Yp(a,this))
    }
    ;
    var Yp=function(a,b){
        Ig[J](this,a);
        Ja(this,b[Bc]);
        this.x=b[Bc][0];
        this.y=b[Bc][1];
        this.z=b[Bc][2];
        this.duration=b.duration;
        this.progress=b.progress;
        this.fps=b.fps_;
        this.state=b.state_;
        this.anim=b
    }
    ;
    U(Yp,Ig);
    var Zp=function(a){
        return 1-r.pow(1-a,3)
    }
    ;
    var $p=function(a,b,c){
        var e=Ki("div",{
style:"overflow:hidden"
        }
        );
        b=zi(b);
        b[O][pb](e,b);
        e[v](b);
        this.elWrapper_=e;
        this.anim_=j;
        lo[J](this,a,b,c);
        a=this.expanded_;
        Wa(this.elWrapper_[H],a?"":"none");
        this.updateHeaderClassName_(a)
    }
    ;
    U($p,lo);
    Q=$p[y];
    Q.animationDuration=500;
    Q.animationAcceleration=Zp;
    Q.setExpanded=function(a){
        if(!(this.expanded_==a&&!this.anim_)){
            if(this.elWrapper_[H][ld]=="none")Wa(this.elWrapper_[H],"");
            var b=this.elContent_[td],c=0;
            if(this.anim_){
                a=this.expanded_;
                ph(this.anim_);
                this.anim_[cb](k);
                c=b-r.abs(da(this.elContent_[H].marginTop,10))
            }
            else c=a?0:b;
            this.updateHeaderClassName_(a);
            this.anim_=new Tp([0,c],[0,a?b:0],this.animationDuration,this.animationAcceleration);
            b=["begin","animate","end"];
            Y(this.anim_,b,this.onAnimate_,k,this);
            Y(this.anim_,"end",T(this.onAnimationCompleted_,
            this,a));
            this.anim_.play(k)
        }
    }
    ;
    Q.onAnimate_=function(a){
        var b=this.elContent_[td];
        this.elContent_[H].marginTop=a.y-b+"px"
    }
    ;
    Q.onAnimationCompleted_=function(a){
        if(a)this.elContent_[H].marginTop="0";
        ph(this.anim_);
        this.expanded_=a;
        this.anim_=j;
        if(!a)Wa(this.elWrapper_[H],"none");
        this[F](new mo("toggle",this,a))
    }
    ;
    var aq=function(a,b){
        this.dataManager_=a;
        this.data_=b;
        this.iterationIndex_=0;
        this.rawEntities_=b.entry
    }
    ;
    aq[y].next=function(){
        if(this.iterationIndex_>=this.rawEntities_[x])return j;
        var a=this.rawEntities_[this.iterationIndex_];
        ++this.iterationIndex_;
        return this.createEntity_(a)
    }
    ;
    aq[y].createEntity_=function(){
        return j
    }
    ;
    aq[y].getLength=function(){
        return this.rawEntities_?this.rawEntities_[x]:0
    }
    ;
    var bq=function(a,b,c,e){
        aq[J](this,a,b);
        this.user_=c;
        if(!this.user_)if(b.user)this.user_=a.getUser(b.user,b.nickname);
        this.album_=e
    }
    ;
    U(bq,aq);
    bq[y].createEntity_=function(a){
        var b=a.author&&a.author[0]?j:this.user_;
        b=this.dataManager_.getPhoto(a,b,this.album_);
        b.updateFromFeedEntity(a);
        return b
    }
    ;
    var cq=function(a){
        if(Od(a))this.uri_=new Sh(a);
        else if(a instanceof Sh)this.uri_=a;
        else d(l("Undefined object: "+a));
        this.uri_.setParameterValue("kind","photo");
        this.uri_.setParameterValue("alt","jsonm");
        this.entity_=j
    }
    ;
    na(cq[y],function(){
        return"Source: "+this.uri_.getPath()
    }
    );
    var dq=/(\/user\/).*(\/|$)/,eq=/\/user\/([^\/\?]{
        3,
    }
    )/;
    Q=cq[y];
    Q.url=function(){
        return this.uri_[db]()
    }
    ;
    Q.setImageMax=function(a){
        this.uri_.setParameterValue("imgmax",m(a))
    }
    ;
    Q.setThumbnailSizes=function(a){
        a=Md(a)?a[ud](","):m(a);
        this.uri_.setParameterValue("thumbsize",a)
    }
    ;
    Q.isCrowded=function(){
        return k
    }
    ;
    Q.setBlock=function(a,b){
        this.uri_.setParameterValue("start-index",m(a));
        this.uri_.setParameterValue("max-results",m(b))
    }
    ;
    Q.setUser=function(a){
        this.uri_.setPath(this.uri_.getPath()[B](dq,"$1"+a+"$2"))
    }
    ;
    Q.getUser=function(){
        var a=eq[rb](this.url());
        if(a&&a[x]>1)return a[1];
        return""
    }
    ;
    Q.getEntities=function(a,b){
        var c=new this.entityIteratorConstructor_(a,b);
        return c
    }
    ;
    Q.getEntity=function(){
        return this.entity_
    }
    ;
    var fq=function(a){
        cq[J](this,a);
        this.entityIteratorConstructor_=bq
    }
    ;
    U(fq,cq);
    Q=fq[y];
    Q.user_=j;
    Q.album_=j;
    na(Q,function(){
        return"AlbumSource: "+this.uri_.getPath()
    }
    );
    Q.entityIteratorConstructor_=bq;
    Q.getAlbumFromJson_=function(a,b){
        var c=a.getAlbum(b.user,b.gphoto$id,b[ib],"");
        c.updateFromFeed(b);
        return c
    }
    ;
    Q.getEntities=function(a,b){
        if(this.entity_)this.entity_.updateFromEntry(b);
        else this.entity_=this.getAlbumFromJson_(a,b);
        if(this.entityIteratorConstructor_==bq){
            var c=a.getUser(b.user,b.nickname);
            return new this.entityIteratorConstructor_(a,b,c,this.entity_)
        }
        else return fq.superClass_.getEntities[J](this,a,b)
    }
    ;
    var gq=/\?.*$/,hq=[/^s\d+$/i,/^w\d+$/i,/^c$/i,/^d$/i,/^h\d*$/i],jq=function(a){
        a=a[B](gq,"");
        a=a[Fb]("/");
        var b;
a:{
            b=a[xb](0,a[x]-1);
            var c=iq,e=b[x],f=Od(b)?b[Fb](""):b;
            for(e=e-1;
            e>=0;
            e--)if(e in f&&c[J](void 0,f[e],e,b)){
                b=e;
                break a
            }
            b=-1
        }
        b>=0&&Re(a,b);
        return a[ud]("/")
    }
    ,kq=function(a,b,c,e,f,g,h){
        var n=a[yc]("/"),o=a[Ed](0,n);
        n=a[Ed](n);
        if(h)return o+"/d"+n;
        h=!!g;
        var s=!!b;
        if(!h&&!s)return a;
        if(!s)f=e=c=ba;
        var A;
        if(s){
            A=b instanceof mi?r.max(b[z],b[P]):b;
            if(!A)return a
        }
        a=[];
        b=k;
        if(e){
            a[w]("w"+A);
            if(c){
                a[w]("c");
                b=i
            }
        }
        if(f){
            a[w]("h"+A);
            if(c&&!b){
                a[w]("c");
                b=i
            }
        }
        s&&!e&&!f&&a[w]("s"+A);
        c&&!b&&a[w]("c");
        h&&a[w]("f"+g[Fb](";
")[ud](":"));
        return o+"/"+a[ud]("-")+n
    }
    ,iq=function(a){
        a=a[Fb]("-");
        for(var b=0,c=0;
        c<hq[x]&&b<a[x];
        c++)a[b][nc](hq[c])&&b++;
        return b==a[x]
    }
    ;
    var lq="",mq=S._features&&!S._features.default144thumbnails?[72,94,110,128,160,220,288]:[72,94,110,144,160,220,288];
    var nq={
    }
    ;
    S.pwa&&S.pwa.paths&&mf(nq,S.pwa.paths);
    var pq=function(a,b){
        var c=r[ub](r.max(a[z],a[P]));
        if(c){
            var e;
            e=b||oq;
            for(var f=e[0],g=1;
            g<e[x];
            g++)if(c>=e[g])f=e[g];
            else break;
            e=f;
            if(a[z]>a[P]){
                ta(a,e);
                Xa(a,r[ub](a[P]*e/c))
            }
            else{
                Xa(a,e);
                ta(a,r[ub](a[z]*e/c))
            }
        }
        else a[ub]();
        return a
    }
    ,oq=[32,48,64,72,80,90,94,104,110,120,128,144,150,160,200,220,288,320,400,512,576,640,720,800,912,1024,1152,1280,1440,1600],qq=[32,48,64,72,80,104,136,144,150,160],rq=new mi(oq[0],oq[0]),sq=rq;
    var uq=function(a){
        this.entries_=[];
        if((this.rawFeed_=a)&&a.entry){
            a=a.entry;
            Ze(a,function(f,g){
                var h=f.nickname?f.nickname:f.scope[D],n=g.nickname?g.nickname:g.scope[D];
                return h<n?-1:h>n?1:0
            }
            );
            for(var b=0;
            b<a[x];
            b++){
                var c=new tq(a[b]),e=this.getIndex(c.getEmail());
                if(e>=0){
                    c=a[b].role$value;
                    this.entries_[e].setRole(c,i)
                }
                else this.entries_[w](c)
            }
        }
    }
    ;
    uq[y].get=function(a){
        return this.entries_[a]
    }
    ;
    uq[y].getIndex=function(a){
        return Pe(this.entries_,function(b){
            return b.getEmail()==a
        }
        ,this)
    }
    ;
    Ia(uq[y],function(a){
        Re(this.entries_,a)
    }
    );
    var tq=function(a){
        this.rawEntry_=a;
        this.roles_={
        }
        ;
        this.parseEntry_()
    }
    ;
    Q=tq[y];
    Q.displayName_=j;
    Q.user_=j;
    Q.getEmail=function(){
        return this.email_
    }
    ;
    Q.getDisplayName=function(){
        return this.displayName_||this.email_
    }
    ;
    Q.parseEntry_=function(){
        var a=this.rawEntry_.scope;
        this.user_=this.rawEntry_.user;
        this.email_=a[D];
        if(a[Zc]=="user")this.scope_="user";
        else if(a[Zc]=="group")this.scope_="group";
        a=this.rawEntry_.role$value;
        this.setRole(a,i);
        if(a=="none")this.scope_="invite";
        if(this.rawEntry_.nickname)this.displayName_=this.rawEntry_.nickname
    }
    ;
    Q.setRole=function(a,b){
        if(a=="none"){
            if(b)for(var c=this.roles_,e=ff(c),f=e[x]-1;
            f>=0;
            f--)hf(c,e[f])
        }
        else this.roles_[a]=b
    }
    ;
    var wq=function(a){
        this.dataManager_=a;
        this.rewriteSpec_=new vq
    }
    ;
    U(wq,uh);
    Q=wq[y];
    Q.id="-1";
    Q.feedLink_="";
    Q.feed_=j;
    Q.htmlLink_="";
    Q.entryLink_="";
    Q.svLink="";
    Q.initLinksFlag_=i;
    Q.updateFromFeed=function(){
    }
    ;
    Q.updateFromFeedEntity=function(a){
        this.mergeEntry(a)
    }
    ;
    Q.updateFromEntry=function(a){
        this.mergeEntry(a)
    }
    ;
    Q.mergeEntry=function(a){
        if(this.rawEntity_){
            var b=Me(this.rawEntity_.link,function(c){
                return!xq(a.link,c)
            }
            );
            Ve(a.link,b);
            mf(this.rawEntity_,a)
        }
        else this.rawEntity_=a;
        this.initLinksFlag_=i
    }
    ;
    var xq=function(a,b){
        return Pe(a,function(c){
            return c.rel==b.rel
        }
        )>-1
    }
    ;
    Q=wq[y];
    Q.rewriteLinks=function(a){
        this.rewriteSpec_=a;
        this.initLinksFlag_=i
    }
    ;
    Q.rewriteLink_=function(a){
        if(this.rewriteSpec_){
            a=new Sh(a);
            var b=a.getDomain();
            if(b==this.rewriteSpec_.oldDomain)a.setDomain(this.rewriteSpec_.newDomain||"");
            b=a.getPort();
            b==this.rewriteSpec_.oldPort&&a.setPort(this.rewriteSpec_.newPort);
            return a[db]()
        }
        else return a
    }
    ;
    Q.initLinks_=function(){
        if(this.initLinksFlag_&&this.rawEntity_){
            this.initLinksFlag_=k;
            if(this.rawEntity_&&this.rawEntity_.link){
                var a=this.rawEntity_.link;
                this.acl_=j;
                for(var b=0;
                b<a[x];
                ++b){
                    var c=a[b],e=c[Rc]||"";
                    switch(c.rel){
                    case "http://schemas.google.com/g/2005#feed":this.feedLink_=this.rewriteLink_(e);
                        break;
                    case "alternate":this.htmlLink_=e;
                        break;
                    case "self":if(ve(e,"/entry/"))this.entryLink_=this.rewriteLink_(e);
                        break;
                    case "edit":this.editLink_=this.rewriteLink_(e);
                        break;
                    case "http://schemas.google.com/acl/2007#accessControlList":this.acl_=
                        new uq(c.feed);
                        break;
                    case "http://schemas.google.com/photos/2007#streetView":this.svLink=e
                    }
                }
            }
            if(!this.acl_)this.acl_=new uq(j)
        }
    }
    ;
    Q.getSource=function(){
        return this.source_
    }
    ;
    Q.getTitle=function(){
        return this.rawEntity_?this.rawEntity_[ib]:""+this
    }
    ;
    Q.getFeedUrl=function(){
        this.initLinks_();
        return this.feedLink_
    }
    ;
    Q.getEntryUrl=function(){
        this.initLinks_();
        return this.entryLink_
    }
    ;
    Q.getHtmlUrl=function(a){
        this.initLinks_();
        var b=this.htmlLink_;
        if(a){
            b=new Sh(b);
            b.setParameterValue("feat",a);
            b=b[db]()
        }
        return b
    }
    ;
    Q.getFeed=function(a){
        this.feed_||this.initializeFeed_(a);
        return this.feed_
    }
    ;
    Q.initializeFeed_=function(a){
        this.feed_=this.dataManager_.getFeedForEntity(this,a)
    }
    ;
    Q.getTransport=function(){
        return this.feed_?this.feed_.getTransport():this.dataManager_.getDefaultTransport()
    }
    ;
    Q.getId=function(){
        return this.id||"-1"
    }
    ;
    Q.thumbnail=function(a){
        var b="img/picasalogo.gif",c=new mi(27,25),e=this.getBaseContent();
        if(e){
            a=r.min(a||0,mq[x]);
            a=mq[a];
            a=new mi(a,a);
            b=e.url||b;
            if("width"in e&&"height"in e){
                ta(c,e[z]);
                Xa(c,e[P]);
                e=a;
                a=c.clone();
                if(a.fitsInside(e)||a.fitsInside(rq))e=a;
                else{
                    a.scaleToFit(e);
                    e=pq(a,oq)
                }
                if(!ni(c,e)){
                    b=kq(b,e);
                    c=e
                }
            }
            else{
                e=c=a;
                a=c.clone();
                if(a.fitsInside(sq))c=sq;
                else{
                    var f=r.min(a[z],a[P]);
                    ta(a,f);
                    Xa(a,f);
                    if(ni(a,c)&&a.fitsInside(e))c=a;
                    else{
                        a.scaleToFit(e);
                        c=pq(a,qq)
                    }
                }
                b=kq(b,c,i)
            }
        }
        return{
url:b,
height:m(c[P]),width:m(c[z])
        }
    }
    ;
    Q.updateFeed=function(a){
        if(!this.feed_)this.feed_=a
    }
    ;
    wa(Q,function(a){
        this.isLoaded()?a(this):this.load_(a)
    }
    );
    Q.reload=function(a){
        this.load_(a)
    }
    ;
    Q.load_=function(a){
        var b=this.getTransport();
        b[pc](this.getEntryUrl(),T(function(c){
            if(c.status==404)typeof this.setDeleted_!="undefined"&&this.setDeleted_();
            else{
                c=c.getResponseJson();
                this.updateFromEntry(c.entry)
            }
            a(this)
        }
        ,this))
    }
    ;
    Q.getCount=function(){
        if(this.rawEntity_)return fa(this.rawEntity_.numPhotos);
        return 0
    }
    ;
    Q.isLoaded=function(){
        return!!this.rawEntity_
    }
    ;
    Q.getThumbnailUrl=function(a){
        a=this.thumbnail(a);
        return a.url
    }
    ;
    Q.getBaseContent=function(){
        if(this.rawEntity_){
            var a=this.rawEntity_[mc];
            if((a=a?a[Hb]:j)&&a[x])return a[0]
        }
        return j
    }
    ;
    Q.getContentUrl=function(){
        var a=this.getBaseContent();
        if(a)return this.normalizeUnreservedChars_(a.url);
        return j
    }
    ;
    Q.getAspectRatio=function(){
        var a,b=this.thumbnail();
        if(b)a=b[z]/b[P];
        return a||0
    }
    ;
    var zq=function(a){
        var b=j;
        if(a){
            var c;
            if("lat"in a&&"lon"in a)c=a.lat+" "+a.lon;
            if(a=a.georss$where){
                var e=a.gml$Point;
                if(e)c=e.gml$pos
            }
            if(c)b=yq(c);
            if(b&&a)if(a=a.gml$Envelope){
                c=a.gml$lowerCorner;
                a=a.gml$upperCorner;
                if(c&&a){
                    c=yq(c);
                    a=yq(a);
                    if(c&&a)b.bb={
ll:c,ur:a
                    }
                }
            }
        }
        return b
    }
    ,yq=function(a){
        if(a){
            var b=a[Fb](" ");
            if(b[x]==2){
                a=fa(b[0]);
                b=fa(b[1]);
                var c;
a:{
                    if(a!=j&&b!=j)if((Pd(a)||!ee(a))&&(Pd(b)||!ee(b))){
                        c=fa(a);
                        var e=fa(b);
                        c=!ia(c+e);
                        break a
                    }
                    c=k
                }
                if(c)return{
lat:a,lon:b
                }
            }
        }
        return j
    }
    ;
    wq[y].normalizeUnreservedChars_=function(a){
        return a[B](/%2D/gi,"-")[B](/%2E/gi,".")[B](/%5F/gi,"_")[B](/%7E/gi,"~")
    }
    ;
    var vq=function(){
        this.newPort=this.oldPort=this.newDomain=this.oldDomain=j
    }
    ;
    var Aq=function(a,b,c,e,f){
        wq[J](this,a);
        this.username=b;
        this.id=c;
        qa(this,e);
        Ua(this,e);
        this.ctitle=f;
        this.link="/lh/sredir?uname="+this.username+"&target=ALBUM&id="+this.id;
        this.prints=k
    }
    ;
    U(Aq,wq);
    Q=Aq[y];
    Oa(Q,"Album");
    Q.setAccess=function(a){
        if(a)this.access_=a
    }
    ;
    Q.setOrganizationName=function(a){
        this.organizationName_=a
    }
    ;
    Q.getBaseContent=function(){
        if(this.rawEntity_&&this.rawEntity_[mc])return Aq.superClass_.getBaseContent[J](this);
        var a="img/picasalogo.gif";
        if(this.largepreview)a=jq(this.largepreview);
        return{
url:a
        }
    }
    ;
    na(Q,function(){
        return"[Album: "+this[ib]+", user: "+this.username+"]"
    }
    );
    Q.getEntryUrl=function(){
        this.initLinks_();
        if(!this.entryLink_)this.entryLink_=de("/data/entry/api/user/%s/albumid/%s?alt=jsonm",this.username,this.id);
        return this.entryLink_
    }
    ;
    Q.updateFromFeed=function(a){
        this.rawEntity_||this.updateFromFeedEntity(a)
    }
    ;
    Q.mergeEntry=function(a){
        Aq.superClass_.mergeEntry[J](this,a);
        this.link=this.getHtmlUrl()||this.link;
        qa(this,this[ib]||this.rawEntity_[ib]);
        this.ctitle=this.ctitle||this.rawEntity_.gphoto$name;
        Ua(this,this[N]||this.ctitle);
        this.location_=this.location_||this.rawEntity_[Rb];
        this.access_=this.access_||this.rawEntity_.access;
        this.organizationName_=this.organizationName_||(this.rawEntity_.organization?this.rawEntity_.organization[N]:j);
        this.prints=a.allowPrints&&a.allowPrints!="false";
        if(a=zq(a)){
            if(ia(this.lat))this.lat=
            a.lat;
            if(ia(this.lon))this.lon=a.lon;
            if(a.bb)this.bb=a.bb
        }
    }
    ;
    Q.getSource=function(){
        if(!this.source_)this.source_=new fq(this.getFeedUrl());
        return this.source_
    }
    ;
    Q.getCount=function(){
        if(this.rawEntity_)return fa(this.rawEntity_.totalResults||this.rawEntity_.numPhotos);
        return 0
    }
    ;
    var Bq=function(a,b,c,e,f){
        this.feed_=a;
        this.blocksToLoad_=b;
        this.index_=c;
        this.count_=e;
        this.fn_=f;
        this.unloadedBlocks_=this.blocksToLoad_[x];
        this.feed_[Lc]("itemsadded",T(this[Eb],this));
        for(a=0;
        a<this.blocksToLoad_[x];
        ++a)this.feed_.loadBlock(this.blocksToLoad_[a])
    }
    ;
    Bq[y].complete_=k;
    Bq[y].isComplete=function(){
        return this.complete_
    }
    ;
    wa(Bq[y],function(){
        if(this.complete_)return i;
        for(var a=[],b=0;
        b<this.blocksToLoad_[x];
        ++b){
            var c=this.blocksToLoad_[b];
            this.feed_.loadedBlocks_[c]||a[w](c)
        }
        if(a[x]==0){
            this.complete_=i;
            this.feed_.removeEventListener("itemsadded",this[Eb][gd],k,this);
            this.fn_(this.feed_,this.index_,this.count_);
            return i
        }
        else this.blocksToLoad_=a;
        return k
    }
    );
    var Cq=function(a,b,c,e){
        this.dataManager_=a;
        this.source_=b;
        this.transport_=c||a.getDefaultTransport();
        this.eventHandler_=new jj(this);
        this.eventHandler_.listen(this.dataManager_,"deleteinitiated",this.handleDeleteInitiated_);
        this.eventHandler_.listen(this.dataManager_,"deletesucceeded",this.handleDeleteSucceeded_);
        this.eventHandler_.listen(this.dataManager_,"deletefailed",this.handleDeleteFailed_);
        this.items_=[];
        this.loadedBlocks_=[];
        this.pendingDeletions_=new qf;
        this.pageSize_=Pd(e)?e:24;
        this.resetAll_()
    }
    ;
    U(Cq,uh);
    Q=Cq[y];
    Q.totalItems_=j;
    Q.crowdedLength_=0;
    Q.relatedKeywords_=j;
    Q.pendingMarkers_=k;
    na(Q,function(){
        return"Feed: "+this.source_
    }
    );
    Q.setEntityWatcher=function(a){
        this.entityWatcher_=a
    }
    ;
    Q.resetAll_=function(){
        this[ed]()
    }
    ;
    Q.getSource=function(){
        return this.source_
    }
    ;
    Ta(Q,function(){
        this.totalItems_=j;
        this.crowdedLength_=0;
        this.relatedKeywords_=j;
        this.items_=[];
        this.loadedBlocks_=[]
    }
    );
    Q.dispose=function(){
        Cq.superClass_.dispose[J](this);
        this[ed]()
    }
    ;
    Q.getTransport=function(){
        return this.transport_
    }
    ;
    Q.findItem=function(a){
        return Ke(this.items_,a)
    }
    ;
    Q.getAllItems=function(){
        return this.items_
    }
    ;
    Q.blockForIndex_=function(a){
        return r[Gb](a/this.pageSize_)
    }
    ;
    Q.loadBlock=function(a){
        this.loadedBlocks_[a]=i;
        var b=a*this.pageSize_,c=b+1;
        if(!(c>1E3)){
            var e=r.min(this.pageSize_,1E3-c+1);
            if(!(e<=0)){
                if(this.pendingMarkers_)for(var f=b;
                f<b+e;
                ++f)this.items_[f]="PENDING";
                this.source_.setBlock(c,e);
                this.transport_[pc](this.source_.url(),T(Cq[y].processItems_,this,a*this.pageSize_,this.pageSize_),T(this.handleError_,this),T(this.handleTimeout_,this))
            }
        }
    }
    ;
    Q.handleTimeout_=function(a){
        if(a){
            var b=a[I];
            b&&lh(b,"timeout",T(this.handleTimeout_,this))
        }
        a={
type:"error",status:"timeout",value:a?a[cc].getStatusText():""
        }
        ;
        this[F](a)
    }
    ;
    Q.handleError_=function(a){
        var b;
        if(a){
            b=a[I];
            lh(b,"error",T(this.handleError_,this))
        }
        var c;
        if(b){
            a=b.getResponseText();
            b=new Sh(b.getLastUri());
            if("too_many_results_requested"==a)c=b.getParameterValue("start-index");
            else if("query_string_too_long"==a)c=(c=b.getParameterValue("q"))?c[x]:-1
        }
        else a="unknown";
        a={
type:"error",status:a,value:""+c
        }
        ;
        this[F](a)
    }
    ;
    Q.processItems_=function(a,b,c){
        if(c.getStatus()==500){
            b=c.getResponseText();
            c="";
            if("too_many_results_requested"==b)c=""+a;
            else if("query_string_too_long"==b){
                a=this.source_.getQuery();
                c=""+a[x]
            }
            this[F]({
type:"error",status:b,value:c
            }
            )
        }
        else this.processJson(a,c.getResponseJson())
    }
    ;
    Q.processJson=function(a,b){
        if(b){
            var c=this.totalItems_,e=b.feed;
            this.totalItems_=fa(e.totalResults);
            this.crowdedLength_=r.max(this.crowdedLength_,fa(e.crowdedLength||this.totalItems_));
            this.relatedKeywords_=e.relatedKeyword;
            0==this.totalItems_&&this[F]("noitems");
            this.addItems_(a,e);
            c!=this.totalItems_&&this[F]("totalchanged")
        }
    }
    ;
    Q.addItems_=function(a,b){
        if(b){
            var c=this.source_.getEntities(this.dataManager_,b),e=r.min(a+c.getLength(),this.totalItems_),f=e-a;
            pa(this.items_,r.max(this.items_[x],e));
            for(e=0;
            e<f;
            ++e){
                var g=a+e,h=c.next();
                this.addItem_(g,h)
            }
            (c=this.source_.getEntity())&&c.updateFeed(this);
            this[F]({
type:"itemsadded",offset:a,count:f,crowdedCount:this.displayItemCount()
            }
            )
        }
    }
    ;
    Q.addItem_=function(a,b){
        if(!(this.items_[a]&&this.items_[a]!="PENDING")){
            this.entityWatcher_&&this.entityWatcher_(b,a);
            this.items_[a]=b
        }
    }
    ;
    wa(Q,function(a,b,c){
        var e=this.blockForIndex_(a),f=this.blockForIndex_(a+b-1),g=[];
        for(e=e;
        e<=f;
        ++e)this.loadedBlocks_[e]||g[w](e);
        if(g[x]==0){
            c(this,a,b);
            return i
        }
        else{
            a=new Bq(this,g,a,b,c);
            return a.isComplete()
        }
    }
    );
    Q.loadAll=function(a){
        var b=1E3;
        if(this.isLoaded()){
            b=r.min(this.totalItems_,b);
            if(this.items_[x]==b){
                a(this,0,b);
                return
            }
        }
        this.source_.setBlock(1,b);
        var c=T(function(e){
            this.processItems_(0,b,e);
            a(this,0,this.totalItems_)
        }
        ,this);
        this.transport_[pc](this.source_.url(),c,T(this.handleError_,this),T(this.handleTimeout_,this))
    }
    ;
    Q.isLoaded=function(){
        return j!=this.totalItems_
    }
    ;
    Q.displayItemCount=function(){
        return r.min(this.crowdedLength_||this.totalItems_,1E3)
    }
    ;
    Q.handleDeleteInitiated_=function(a){
        a=a[I];
        var b=this.findItem(a);
        b>=0&&this[wc](b)&&this.pendingDeletions_.set(a.id,[a,b])
    }
    ;
    Ia(Q,function(a){
        var b=k;
        if(Re(this.items_,a)){
            b=i;
            --this.crowdedLength_
        }
        --this.totalItems_;
        this[F]("totalchanged");
        return b
    }
    );
    Q.handleDeleteSucceeded_=function(a){
        a=a[I];
        this.pendingDeletions_[wc](a.id)
    }
    ;
    Q.handleDeleteFailed_=function(a){
        a=a[I];
        var b=this.pendingDeletions_.get(a.id);
        if(b){
            Xe(this.items_,b[1],0,b[0]);
            this.pendingDeletions_[wc](a.id);
            ++this.crowdedLength_
        }
        ++this.totalItems_;
        this[F]("totalchanged")
    }
    ;
    var Dq=function(a,b,c,e){
        wq[J](this,a);
        this.updateFromFeedEntity(b);
        this.user=c;
        this.album=e
    }
    ;
    U(Dq,wq);
    Oa(Dq[y],"Tag");
    na(Dq[y],function(){
        var a="Tag "+this.t;
        if(this.user)a+=", user: "+this.user;
        if(this.album)a+=", album: "+this.album;
        return a
    }
    );
    Dq[y].updateFromFeedEntity=function(a){
        this.t=a[ib];
        this.w=a.weight?a.weight:1
    }
    ;
    var Eq=function(a,b,c,e){
        this.url_=a;
        if(b&&c)this.size_=new mi(b,c);
        this.type_=e||""
    }
    ;
    Eq[y].getUrl=function(){
        return this.url_
    }
    ;
    Eq[y].getType=function(){
        return this.type_
    }
    ;
    var Fq=function(a,b,c,e){
        wq[J](this,a);
        this.deleted_=k;
        this.src="../img/picasaweblogo-en_US.gif";
        this.user=c;
        this.album=e||j;
        this.comments_=[];
        this.albumInfos_=[];
        if(b){
            this.updateCommonFields_(b);
            a=b.author;
            if(!this.user&&a){
                c=a[0];
                a=c.email;
                c=c[N]||a;
                this.user=this.dataManager_.getUser(a,c)
            }
            if(!this.album&&this.user){
                this.album=this.dataManager_.getAlbum(this.user[N],this.getAlbumId(),this.getAlbumTitle(),this.getAlbumCTitle());
                this.album.setAccess(b.access);
                b.organization&&this.album.setOrganizationName(b.organization[N])
            }
            this.loaded_=
            i
        }
    }
    ;
    U(Fq,wq);
    Oa(Fq[y],"Photo");
    var Gq=Of("gphoto.api.Photo");
    Q=Fq[y];
    Q.log_=function(a){
        Gq.fine(a)
    }
    ;
    Q.deleted_=k;
    Q.printable_=k;
    Q.downloadable_=k;
    Q.licenseOverride_=k;
    Q.license_="";
    Q.albumId_="";
    Q.commentingEnabled_=k;
    Q.detailLoadingState_=0;
    Q.data_=j;
    Q.loaded_=k;
    Q.rawTagData_="";
    Q.getAlbum=function(){
        return this.album
    }
    ;
    Q.getAlbumId=function(){
        return this.albumId_
    }
    ;
    Q.getAlbumTitle=function(){
        return this.albumTitle_
    }
    ;
    Q.getAlbumCTitle=function(){
        return this.albumCTitle_
    }
    ;
    na(Q,function(){
        return"Photo "+this.t+", in album: "+this.album+", user: "+this.user
    }
    );
    Q.getFeed=function(){
        return j
    }
    ;
    Q.loadDetail=function(a){
        if(this.isDetailLoaded())a(this);
        else{
            kh(this,"photoDataReady",function(){
                a(this)
            }
            ,k,this);
            this.loadData_()
        }
    }
    ;
    Q.isDetailLoaded=function(){
        return this.detailLoadingState_==2
    }
    ;
    Q.isDetailLoading=function(){
        return this.detailLoadingState_==1
    }
    ;
    Q.setDetailLoadingState=function(a){
        this.detailLoadingState_=a
    }
    ;
    Q.getEntryUrl=function(){
        this.initLinks_();
        if(!this.entryLink_)this.entryLink_=de("/data/entry/api/user/%s/albumid/%s/photoid/%s?alt=jsonm",this.user[N],this.album.id,this.id);
        return this.entryLink_
    }
    ;
    Q.loadData_=function(){
        if(!this.isDetailLoading())if(this.isDetailLoaded())this[F]("photoDataReady");
        else if(this.user[N]){
            this.setDetailLoadingState(1);
            var a=this.getFeedUrl();
            a+="&nocache="+$d();
            this.getTransport()[pc](a,T(this.feedLoaded_,this))
        }
        else{
            this.loaded_=i;
            this.data_=j;
            this.setDeleted_()
        }
    }
    ;
    Q.thumbnail=function(a){
        var b,c=this.videostatus;
        b="";
        if(c=="ready")b="img/video_ready.png";
        else if(c=="pending")b="img/video_pending.png";
        else if(c=="failed")b="img/video_failed.png";
        if(b){
            c=q[xd]("base")[0][Rc];
            b=c+b
        }
        b=b;
        if(!b)return Fq.superClass_.thumbnail[J](this,a);
        a=new mi(288,216);
        return{
url:b,height:m(a[P]),width:m(a[z])
        }
    }
    ;
    Q.feedLoaded_=function(a){
        try{
            this.setDetailLoadingState(2);
            var b=a.getStatus();
            if(b>=400){
                this.setDeleted_();
                return
            }
            this.updateFromFeedEntity(a.getResponseJson().feed)
        }
        catch(c){
            this.log_(m(c));
            return
        }
        this.isDetailLoaded()&&this[F]("photoDataReady")
    }
    ;
    Q.updateFromEntry=function(a){
        wq[y].updateFromEntry[J](this,a);
        this.updateCommonFields_(a);
        if(this.rawEntity_&&a&&a[mc])this.rawEntity_[mc].keywords=a[mc].keywords;
        this.loaded_=i
    }
    ;
    Q.updateCommonFields_=function(a){
        wq[y].updateFromEntry[J](this,a);
        var b=a[mc],c=b[Hb][0];
        this.s=this.normalizeUnreservedChars_(c.url);
        this.id=a.gphoto$id;
        this.w=fa(a[z]||c[z]);
        this.h=fa(a[P]||c[P]);
        this.setCaption(se(b.description));
        this.t=se(b[ib]);
        this.exifData_=a.exif;
        this.filename_=a[ib];
        this.date_=a.timestamp||this.date_;
        this.size_=a.size;
        this.albumId_=a.albumId||this.albumId_;
        this.albumTitle_=a.albumTitle||this.albumTitle_;
        this.albumCTitle_=a.albumCTitle||this.albumCTitle_;
        this.originalVideo_=
        a.gphoto$originalvideo||this.originalVideo_;
        this.albumInfos_=a.albumInfo||this.albumInfos_;
        this.snippet=a.snippet||"";
        this.snippetType=a.snippettype||"";
        this.truncated=a.truncated=="1";
        this.processGeo_(a);
        if(c=!!b[Hb][1]){
            this.videostatus=a.videostatus;
            this.videoStreams_=[];
            for(c=1;
            c<b[Hb][x];
            c++){
                var e=b[Hb][c];
                this.videoStreams_[c-1]=new Eq(e.url,e[z],e[P],e[Zc])
            }
        }
        this.rawTagData_=kf(b,"keywords")||"";
        this.thumbnails_=b.thumbnail;
        this.sanitizedCaption_=a.htmlCaption;
        this.starred_=a.starred=="true";
        this.totalStars_=fa(a.starred$total)||0;
        this.featuredDate_=a.featuredDate
    }
    ;
    Q.updateFromFeedEntity=function(a){
        if(a){
            this.mergeEntry(a);
            this.updateCommonFields_(a);
            if(!this.user){
                var b=a.author[0],c=b.email;
                b=b[N]||c;
                this.user=this.dataManager_.getUser(c,b)
            }
            this.licenseOverride_=!!a.ccOverride;
            this.license_=a.cc;
            this.comments_=a.entry;
            this.printable_=a.allowPrints=="true";
            this.downloadable_=a.allowDownloads=="true";
            this.commentingEnabled_=a.commentingEnabled=="true";
            this.viewCount_=fa(a.viewCount)||0;
            if(!this.album)this.album=this.dataManager_.getAlbum(this.user[N],this.getAlbumId(),
            this.getAlbumTitle(),this.getAlbumCTitle());
            if(this.album){
                a.access&&this.album.setAccess(a.access);
                a.organization&&this.album.setOrganizationName(a.organization[N])
            }
            if(this.isPrintable())if(c=this.getAlbum())c.prints=i;
            this.dl=lq==a.uname||this.isDownloadable();
            this.loaded_=i;
            Fq.superClass_.updateFromFeedEntity[J](this,a);
            if(a.author){
                a=a.author[0];
                if(!this.user[N])Ua(this.user,a.email);
                if(!this.user.nickname)this.user.nickname=a[N]
            }
            this.user[N]||this.setDeleted_()
        }
    }
    ;
    Q.setDeleted_=function(){
        this.deleted_=i;
        this[F]("deleted")
    }
    ;
    Q.getAspectRatio=function(){
        if(Pd(this.w)&&Pd(this.h))return this.w/this.h;
        return 0
    }
    ;
    Q.getContentUrl=function(a,b){
        var c="";
        if(this.s){
            c=jq(this.s);
            if(a)c=kq(c,a,b)
        }
        return c
    }
    ;
    Q.getCaption=function(){
        return this.c
    }
    ;
    Q.setCaption=function(a){
        this.c=we(a,1024)
    }
    ;
    Q.processGeo_=function(a){
        if(a=zq(a)){
            if(ia(this.lat))this.lat=a.lat;
            if(ia(this.lon))this.lon=a.lon;
            if(a.bb)this.bb=a.bb;
            if(this.exifData_){
                this.exifData_.latitude=this.lat;
                this.exifData_.longitude=this.lon
            }
        }
    }
    ;
    Q.getDate=function(){
        return this.date_
    }
    ;
    Q.getTitle=function(){
        return this.t
    }
    ;
    Q.isPrintable=function(){
        return this.printable_
    }
    ;
    Q.isDownloadable=function(){
        return this.downloadable_
    }
    ;
    var Hq=function(a){
        cq[J](this,a);
        this.entityIteratorConstructor_=bq
    }
    ;
    U(Hq,cq);
    Hq[y].setQuery=function(a,b){
        this.uri_.setParameterValue("q",a);
        b!==ba&&this.setCrowding(b)
    }
    ;
    Hq[y].getQuery=function(){
        return m(this.uri_.getParameterValue("q")||"")
    }
    ;
    Hq[y].setCrowding=function(a){
        var b=this.isCrowded();
        if(b!=a)(b=a)?this.uri_.setParameterValue("filter","1"):this.uri_.getQueryData()[wc]("filter")
    }
    ;
    Hq[y].isCrowded=function(){
        return this.uri_.getParameterValue("filter")=="1"
    }
    ;
    var Iq=function(a,b,c,e){
        aq[J](this,a,b);
        this.user_=c;
        this.album_=e
    }
    ;
    U(Iq,aq);
    Iq[y].createEntity_=function(a){
        return this.dataManager_.getTag(a,this.user_,this.album_)
    }
    ;
    var Jq=function(a){
        cq[J](this,a);
        this.entityIteratorConstructor_=Iq
    }
    ;
    U(Jq,cq);
    na(Jq[y],function(){
        return"TagSource: "+this.uri_.getPath()
    }
    );
    Jq[y].getEntities=function(a,b){
        if(this.entityIteratorConstructor_==Iq){
            var c=a.getUser(b.user,b.nickname),e=j;
            return new this.entityIteratorConstructor_(a,b,c,e)
        }
        else return Jq.superClass_.getEntities[J](this,a,b)
    }
    ;
    var Kq=function(a,b,c){
        aq[J](this,a,b);
        this.user_=c
    }
    ;
    U(Kq,aq);
    Kq[y].createEntity_=function(a){
        var b=this.dataManager_.getAlbum(this.user_[N],a.gphoto$id,a[ib],a.gphoto$name);
        b.updateFromFeedEntity(a);
        return b
    }
    ;
    var Lq=function(a,b){
        cq[J](this,a);
        this.userName_=b;
        this.uri_.setParameterValue("kind","album");
        var c=this.uri_.getPath()[nc](eq);
        if(c&&c[x]>1){
            c=c[1];
            if(c!=this.userName_){
                this.setUser(this.userName_);
                c=this.uri_.getQueryData();
                if(c.containsKey("authkey")){
                    c[wc]("authkey");
                    c[wc]("access")
                }
            }
        }
        this.entityIteratorConstructor_=Kq
    }
    ;
    U(Lq,cq);
    na(Lq[y],function(){
        return"UserSource: "+this.userName_
    }
    );
    Lq[y].getEntities=function(a,b){
        if(this.entityIteratorConstructor_===Kq){
            if(!this.entity_){
                var c=a.getUser(b.user,b.nickname);
                c.updateFromFeed(b);
                this.entity_=c
            }
            return new this.entityIteratorConstructor_(a,b,this.entity_)
        }
        else return Lq.superClass_.getEntities[J](this,a,b)
    }
    ;
    var Mq=function(a,b,c,e){
        wq[J](this,a);
        Ua(this,b);
        this.nickname=c;
        this.icon=kf(nq,"staticimagepath","img/")+"noportrait.jpg";
        this.galleryName=this.nickname;
        this.detailLoaded_=this.loaded=k;
        this.profileUrl=e||"";
        this.email=""
    }
    ;
    U(Mq,wq);
    Q=Mq[y];
    Oa(Q,"User");
    Q.getSource=function(){
        if(!this.source_)this.source_=new Lq(this.getFeedUrl(),this[N]);
        return this.source_
    }
    ;
    Q.updateFromFeed=function(a){
        Mq.superClass_.updateFromFeed[J](this,a);
        this.icon=a.icon;
        this.galleryName=a[ib]
    }
    ;
    na(Q,function(){
        return"User "+this.nickname+", username: "+this[N]
    }
    );
    wa(Q,function(a){
        this.loadDetail(a)
    }
    );
    Q.loadDetail=function(a){
        if(this.detailLoaded_)a(this);
        else{
            Y(this,"userDataReady",function(){
                a(this)
            }
            ,i,this);
            this.loadData_()
        }
    }
    ;
    Q.loadData_=function(){
        if(this.detailLoaded_){
            this.loaded=i;
            this[F]({
type:"userDataReady"
            }
            )
        }
        else{
            var a=this.getEntryUrl()||"/data/entry/api/user/"+this[N]+"?alt=jsonm",b=this.getTransport();
            b[pc](a,T(Mq[y].handleEvent_,this))
        }
    }
    ;
    Q.updateFromFeedEntity=function(a){
        Mq.superClass_.updateFromFeedEntity[J](this,a);
        this.icon=a.thumbnail||this.icon;
        this.galleryName=a[ib];
        Ua(this,a.user);
        this.nickname=a.nickname;
        this.organization=a.organization
    }
    ;
    Q.handleEvent_=function(a){
        if(a=a.getResponseJson()){
            this.loaded=this.detailLoaded_=i;
            this.updateFromFeedEntity(a.entry);
            this[F]({
type:"userDataReady"
            }
            )
        }
    }
    ;
    var Nq=function(){
    }
    ,Oq=function(a,b,c){
        this.status_=a;
        this.message_=b;
        this.json_=c
    }
    ;
    Oq[y].getStatus=function(){
        return this.status_
    }
    ;
    Oq[y].getResponseText=function(){
        return this.message_
    }
    ;
    Oq[y].getResponseJson=function(){
        return this.json_
    }
    ;
    var Pq=function(){
    }
    ;
    U(Pq,Nq);
    var Qq={
        "Content-Type":"application/atom+xml","X-HTTP-Method-Override":"PUT"
    }
    ;
    Ha(Pq[y],function(a,b,c,e,f,g,h){
        if(!h&&f=="POST")h=Qq;
        b=T(this.handleResponse_,this,b,c,e);
        Rh(a,b,f,g,h,3E4)
    }
    );
    Pq[y].handleResponse_=function(a,b,c,e){
        var f=e[I],g=f.getLastErrorCode(),h=f.getStatus(),n;
        if(g||!f.isSuccess())if(g==8){
            if(c){
                c(e);
                return
            }
        }
        else{
            if(b){
                b(e);
                return
            }
        }
        else try{
            var o=f.getResponseText(),s=o?wh(o):j;
            n=new Oq(0,"",s)
        }
        catch(A){
            if(b){
                b(e);
                return
            }
        }
        if(!n){
            b="";
            try{
                b=f.getResponseText()
            }
            catch(G){
            }
            n=new Oq(h,b,j)
        }
        a(n)
    }
    ;
    var Rq=function(a){
        this.photos_=new qf;
        this.albums_=new qf;
        this.users_=new qf;
        this.tags_=new qf;
        this.collectionTypes_={
        }
        ;
        this.collectionTypes_.Album=this.albums_;
        this.collectionTypes_.Photo=this.photos_;
        this.defaultTransport_=a||new Pq;
        this.pendingDeletions_=new qf;
        this.log_=Of("gphoto.api.DataManager")
    }
    ;
    U(Rq,uh);
    Q=Rq[y];
    Ta(Q,function(){
        this.photos_[ad]();
        this.albums_[ad]();
        this.users_[ad]()
    }
    );
    Q.getDefaultTransport=function(){
        return this.defaultTransport_
    }
    ;
    Q.getUserSource=function(a,b){
        var c=de("%s/user/%s/",b||"/data/feed/api",a);
        c=c;
        if(typeof S._features!="undefined"&&S._features.PERFORMANCE_EXPERIMENTS)c=c[B]("/data/feed/api/","/data/feed/t/");
        c=c;
        return new Lq(c,a)
    }
    ;
    Q.getUserFeed=function(a,b,c){
        a=this.getUserSource(a,b);
        return new Cq(this,a,c)
    }
    ;
    Q.getFeedForEntity=function(a,b){
        var c=a.getSource();
        return new Cq(this,c,b||a.getTransport())
    }
    ;
    Q.getAlbum=function(a,b,c,e){
        var f=a+b,g=this.albums_.get(f);
        if(!g){
            g=new Aq(this,a,b,c,e);
            this.albums_.set(f,g)
        }
        return g
    }
    ;
    Q.getUser=function(a,b){
        var c=this.users_.get(a);
        if(!c){
            c=new Mq(this,a,b);
            this.users_.set(a,c)
        }
        return c
    }
    ;
    Q.getPhoto=function(a,b,c){
        if(!a)return j;
        var e=a.gphoto$id,f=this.photos_.get(e);
        if(!f){
            f=new Fq(this,a,b,c);
            this.photos_.set(e,f)
        }
        return f
    }
    ;
    Q.getTag=function(a,b,c){
        if(!a)return j;
        var e=a[ib],f=this.tags_.get(e);
        if(!f){
            f=new Dq(this,a,b,c);
            this.tags_.set(e,f)
        }
        return f
    }
    ;
    var Sq=function(a,b){
        this.uri_=new Sh(a);
        this.callbackParamName_=b?b:"callback";
        this.timeout_=5E3
    }
    ,Tq=0;
    Sq[y].setRequestTimeout=function(a){
        this.timeout_=a
    }
    ;
    Ha(Sq[y],function(a,b,c,e){
        if(!q[Dd][Ec]){
            c&&c(a);
            return j
        }
        e=e||"_"+(Tq++)[db](36)+$d()[db](36);
        S._callbacks_||(S._callbacks_={
        }
        );
        var f=q[K]("script"),g=j;
        if(this.timeout_>0){
            g=Uq(e,f,a,c);
            g=S[yb](g,this.timeout_)
        }
        c=this.uri_.clone();
        a=a;
        var h=c,n;
        for(n in a)if(!a[Zb]||a[Zb](n))h.setParameterValues(n,a[n]);
        if(b){
            b=Vq(e,f,b,g);
            S._callbacks_[e]=b;
            c.setParameterValues(this.callbackParamName_,"_callbacks_."+e)
        }
        Fi(f,{
type:"text/javascript",id:e,charset:"UTF-8",src:c[db]()
        }
        );
        b=q[xd]("head")[0];
        b[v](f);
        return{
            id_:e,timeout_:g
        }
    }
    );
    Sq[y].cancel=function(a){
        if(a&&a.id_){
            var b=zi(a.id_);
            if(b&&b[dd]=="SCRIPT"&&typeof S._callbacks_[a.id_]=="function"){
                a.timeout_&&S[qb](a.timeout_);
                Wq(a.id_,b,k)
            }
        }
    }
    ;
    var Uq=function(a,b,c,e){
        return function(){
            Wq(a,b,k);
            e&&e(c)
        }
    }
    ,Vq=function(a,b,c,e){
        return function(){
            S[qb](e);
            Wq(a,b,i);
            c[$c](ba,arguments)
        }
    }
    ,Wq=function(a,b,c){
        S[yb](function(){
            Ri(b)
        }
        ,0);
        if(S._callbacks_[a])if(c)delete S._callbacks_[a];
        else S._callbacks_[a]=Jd
    }
    ;
    var Xq=function(){
    }
    ;
    U(Xq,Nq);
    Ha(Xq[y],function(a,b,c,e,f){
        if(f&&f!="GET")d(l("Only GET supported in JSONP transport"));
        a=new Sq(a);
        a.setRequestTimeout(3E4);
        b=T(this.handleResponse_,this,b);
        a[pc](j,b,e||c)
    }
    );
    Xq[y].handleResponse_=function(a,b){
        a(new Oq(0,"",b))
    }
    ;
    var Yq=function(a,b,c){
        this.listener_=a;
        this.interval_=b||0;
        this.handler_=c;
        this.callback_=T(this.doAction_,this)
    }
    ;
    U(Yq,Hg);
    Q=Yq[y];
    Q.id_=0;
    Q.disposeInternal=function(){
        Yq.superClass_.disposeInternal[J](this);
        this[cb]();
        delete this.listener_;
        delete this.handler_
    }
    ;
    Q.start=function(a){
        this[cb]();
        this.id_=Dh(this.callback_,a!==ba?a:this.interval_)
    }
    ;
    Q.stop=function(){
        this.isActive()&&Ah[qb](this.id_);
        this.id_=0
    }
    ;
    Q.isActive=function(){
        return this.id_!=0
    }
    ;
    Q.doAction_=function(){
        this.id_=0;
        this.listener_&&this.listener_[J](this.handler_)
    }
    ;
    var Zq=function(a){
        this.element_=a;
        this.inputEventEmulation_=X||ng&&!Dg("531")&&a[dd]=="TEXTAREA";
        this.eventHandler_=new jj;
        this.eventHandler_.listen(this.element_,this.inputEventEmulation_?["keydown","paste","cut","drop"]:"input",this)
    }
    ;
    U(Zq,uh);
    Q=Zq[y];
    Q.timer_=j;
    La(Q,function(a){
        if(this.inputEventEmulation_){
            var b;
            if(b=a[Zc]=="keydown"){
a:if(a[fb]&&!a[Db]||a[Wb]||a[Dc]>=112&&a[Dc]<=123)b=k;
                else switch(a[Dc]){
                case 18:case 20:case 93:case 17:case 40:case 35:case 27:case 36:case 45:case 37:case 224:case 91:case 144:case 12:case 34:case 33:case 19:case 255:case 44:case 39:case 16:case 38:case 224:b=k;
                    break a;
                default:b=i
                }
                b=!b
            }
            if(!b){
                var c=a[Zc]=="keydown"?this.element_[D]:j;
                if(X&&a[Dc]==229)c=j;
                var e=this.createInputEvent_(a);
                this.cancelTimerIfSet_();
                this.timer_=
                Dh(function(){
                    this.timer_=j;
                    this.element_[D]!=c&&this.dispatchAndDisposeEvent_(e)
                }
                ,0,this)
            }
        }
        else if(!lg||this.element_==xi(this.element_)[gb])this.dispatchAndDisposeEvent_(this.createInputEvent_(a))
    }
    );
    Q.cancelTimerIfSet_=function(){
        if(this.timer_!=j){
            Ah[qb](this.timer_);
            this.timer_=j
        }
    }
    ;
    Q.createInputEvent_=function(a){
        a=new Kg(a.getBrowserEvent());
        Oa(a,"input");
        return a
    }
    ;
    Q.dispatchAndDisposeEvent_=function(a){
        try{
            this[F](a)
        }
        finally{
            a.dispose()
        }
    }
    ;
    Q.disposeInternal=function(){
        Zq.superClass_.disposeInternal[J](this);
        this.eventHandler_.dispose();
        this.cancelTimerIfSet_();
        delete this.element_
    }
    ;
    var $q=function(a,b,c){
        this.selectedRow_=-1;
        this.rowMap_=[];
        this.usernameKeyTimeout_=j;
        this.showUsername_=b;
        this.showSubtitle_=c;
        a!=j&&this.setPicker(a);
        this.source_=j;
        this.delay_=new Yq(this.usernameChanged_,2E3,this)
    }
    ;
    Q=$q[y];
    Q.setPicker=function(a){
        this.picker_=a;
        this.doc_=a.getDocument();
        this.eventHandler_=new jj(this);
        this.container_=this.makeListViewContainer_(this.showUsername_,this.showSubtitle_)
    }
    ;
    Q.inputHandler_=j;
    Q.getContainer=function(){
        return this.container_
    }
    ;
    Q.setContainer=function(a){
        this.container_=a
    }
    ;
    Q.sourcesChanged=function(){
        this.populateListView_()
    }
    ;
    Q.activate=function(){
        this.loadList_();
        if(this.usernameField_)try{
            this.usernameField_[zc]()
        }
        catch(a){
        }
    }
    ;
    Q.dispose=function(){
        this.delay_[cb]();
        if(this.eventHandler_){
            this.eventHandler_.dispose();
            this.eventHandler_=j
        }
    }
    ;
    Q.makeListViewContainer_=function(a,b){
        var c=this.doc_[K]("table"),e=this.doc_[K]("tbody"),f=this.doc_[K]("tr"),g=this.doc_[K]("td");
        c[v](e);
        t(c,"mp_dialog");
        e[v](f);
        f[v](g);
        Wi(g,this.picker_.isProfileMode()?"Select a picture of yourself":this.getMsgTitle());
        t(g,"mp_title");
        f=this.doc_[K]("tr");
        e[v](f);
        g=this.doc_[K]("td");
        f[v](g);
        t(g,"mp_middle");
        Xa(g,"100%");
        if(a||b){
            f=this.doc_[K]("p");
            if(b){
                var h=this.doc_[K]("span");
                Wi(h,this.getMsgSubtitle(a));
                f[v](h)
            }
            if(a){
                h=this.doc_[K]("span");
                this.usernameField_=
                this.doc_[K]("input");
                Oa(this.usernameField_,"text");
                this.usernameField_.size="16";
                za(this.usernameField_,this.picker_.getUserId());
                this.inputHandler_=new Zq(this.usernameField_);
                Y(this.inputHandler_,"input",this.usernameInput_,i,this);
                Y(this.usernameField_,"keydown",this.usernameInput_,i,this);
                h[v](this.usernameField_);
                f[v](h)
            }
            g[v](f)
        }
        this.listViewContainer_=this.doc_[K]("div");
        t(this.listViewContainer_,"mp_scroller"+this.picker_.getTheme());
        this.addLoadingMessage_(i);
        this.eventHandler_.listen(this.listViewContainer_,
        "mousedown",this.mouseClicked_);
        this.eventHandler_.listen(this.listViewContainer_,"mouseover",this.mouseOver_);
        this.eventHandler_.listen(this.listViewContainer_,"mouseout",this.mouseOut_);
        g[v](this.listViewContainer_);
        f=this.doc_[K]("tr");
        e[v](f);
        g=this.doc_[K]("td");
        f[v](g);
        t(g,"mp_buttons");
        e=this.doc_[K]("input");
        Oa(e,"submit");
        za(e,this.msgCancelLabel);
        g[v](e);
        this.eventHandler_.listen(e,"click",this.cancelClicked_);
        return c
    }
    ;
    Q.cancelClicked_=function(){
        this.picker_.cancel();
        this.picker_.hide()
    }
    ;
    Q.usernameChanged_=function(){
        if(this.usernameField_){
            var a=this.usernameField_[D],b=this.picker_.getUserId();
            if(a!=b){
                this.picker_.setUserId(a);
                this.loadList_()
            }
        }
    }
    ;
    Q.usernameInput_=function(a){
        if(a[Dc]==13){
            this.usernameChanged_();
            this.delay_[cb]();
            a[Sb]()
        }
        else this.delay_[xc]();
        return i
    }
    ;
    Q.populateListView_=function(){
        var a=this.picker_.getContent();
        this.rowMap_=[];
        this.selectedRow_=-1;
        if(a[x]<1)this.displayErrorMessage(this.msgNoList);
        else{
            Qi(this.listViewContainer_);
            for(var b=0;
            b<a[x];
            b++){
                var c=a[b],e=c.getCount(),f=j;
                f=e==1?this.msgItemLabel:this.getMsgItemCount(e);
                e=this.doc_[K]("div");
                t(e,"mp_list");
                this.listViewContainer_[v](e);
                var g=c.getThumbnailUrl(0)||this.picker_.getPlaceholderImageUrl();
                g=Ki("img",{
align:"left",width:"32",height:"28",src:g
                }
                );
                e[v](g);
                c=Ni(se(c.getTitle())+
                "<br><span class=mp_subtitle>"+se(f));
                e[v](c);
                this.rowMap_[w](e)
            }
        }
    }
    ;
    Q.loadList_=function(){
        var a=this.picker_.getCurrentSource();
        if(a=a.getUrl()){
            a=this.picker_.appendExtraUrlParams(a);
            this.picker_.fetchJSONData(a,0)
        }
        else{
            Qi(this.listViewContainer_);
            a=Ni('<br><br><br><center><font size=4 font color="#4D4D4D">No Images Found.</font></center>');
            this.listViewContainer_[v](a)
        }
    }
    ;
    Q.addLoadingMessage_=function(a){
        var b='<br><br><br><center><font size=4 font color="#4D4D4D">',c=this.picker_.getSpinImageUrl();
        b+=this.picker_.isQueryInProgress()||a?se(this.msgListLoading)+'<img src="'+c+'" hspace="8">':se(this.msgNoList);
        xa(this.listViewContainer_,b+"</font></center>")
    }
    ;
    Q.displayErrorMessage=function(a){
        xa(this.listViewContainer_,'<br><br><br><center><font size="4" font color="#cc0000">'+se(a)+"</font></center>")
    }
    ;
    Q.mouseClicked_=function(a){
        var b=this.getRowIndexFromPosition_(a);
        this.selectItem(b);
        a[Sb]()
    }
    ;
    Q.selectItem=function(a){
        if(a>=0){
            var b=this.picker_.getContent();
            a=b[a];
            this.picker_.setAlbum(a);
            this.picker_.setGridView(this.source_)
        }
    }
    ;
    Q.getRowIndexFromPosition_=function(a){
        var b={
x:a[Bd],y:a[Cd]
        }
        ,c=Hj(this.listViewContainer_);
        a=Hi();
        var e=Mj(this.listViewContainer_);
        b.x+=this.listViewContainer_[Ic]+a.x;
        b.y+=this.listViewContainer_[bb]+a.y;
        a=b.y-c.y+this.container_[bb];
        if(b.x-c.x>=e[z]-16)return-1;
        for(c=b=0;
        c<this.rowMap_[x];
        c++){
            e=this.rowMap_[c];
            e=Mj(e)[P];
            b+=e;
            if(a<=b)return c
        }
        return-1
    }
    ;
    Q.setHighlight_=function(a){
        if(this.selectedRow_!=a){
            if(this.selectedRow_!=-1){
                var b=this.rowMap_[this.selectedRow_];
                t(b,"mp_list")
            }
            this.selectedRow_=a;
            if(a!=-1){
                b=this.rowMap_[a];
                t(b,"mp_list_selected"+this.picker_.getTheme())
            }
        }
    }
    ;
    Q.mouseOver_=function(a){
        a=this.getRowIndexFromPosition_(a);
        this.setHighlight_(a)
    }
    ;
    Q.mouseOut_=function(){
        this.setHighlight_(-1)
    }
    ;
    Q.setSource=function(a){
        this.source_=a
    }
    ;
    var ar=function(a,b,c,e){
        this.title_=a;
        this.type_=b;
        this.id_="-1";
        this.thumbnailUrl_=c;
        this.contentUrl_=e;
        this.itemList_=[];
        this.container_=j;
        this.itemCount_=-1;
        this.description_=j;
        this.loaded_=k;
        this.height_=this.width_=-1
    }
    ;
    Q=ar[y];
    Q.getTitle=function(){
        return this.title_
    }
    ;
    Q.getThumbnailUrl=function(){
        return this.thumbnailUrl_||this.contentUrl_
    }
    ;
    Q.getContentUrl=function(){
        return this.contentUrl_
    }
    ;
    Q.getId=function(){
        return this.id_
    }
    ;
    Q.setId=function(a){
        this.id_=a
    }
    ;
    Q.addItem=function(a){
        this.loaded_=i;
        this.itemList_[w](a);
        a.setContainer(this)
    }
    ;
    Q.setContainer=function(a){
        this.container_=a
    }
    ;
    Q.isLoaded=function(){
        return this.loaded_
    }
    ;
    Q.getCount=function(){
        if(this.itemCount_>=0)return this.itemCount_;
        return this.itemList_[x]
    }
    ;
    Q.setCount=function(a){
        this.itemCount_=a
    }
    ;
    Q.setDescription=function(a){
        this.description_=a
    }
    ;
    Q.setDimensions=function(a,b){
        this.width_=a;
        this.height_=b
    }
    ;
    Q.getAspectRatio=function(){
        if(this.width_==-1||this.height_==-1)return 0;
        return this.width_/this.height_
    }
    ;
    Q.measureImage=function(a){
        this.image_=new Image;
        mg&&q[dc][v](this.image_);
        this.imageHandler_=this.measureImageDone_[gd](this,a);
        this.image_.onload=this.imageHandler_;
        this.image_.src=this.contentUrl_
    }
    ;
    Q.measureImageDone_=function(a){
        this.setDimensions(this.image_[z],this.image_[P]);
        mg&&q[dc][hc](this.image_);
        this.image_=this.imageHandler_=j;
        a&&a()
    }
    ;
    Q.calcDimensions=function(a,b,c){
        var e=a;
        var f=b=b||a;
        c=c?this.getAspectRatio():1;
        if(c>1)f=r[ub](e/c);
        else if(c>0)e=r[ub](f*c);
        if(e>a){
            f=r[ub](f*a/e);
            e=a
        }
        if(f>b){
            e=r[ub](e*b/f);
            f=b
        }
        return{
width:e,height:f
        }
    }
    ;
    Q.getDimensionsLabel=function(){
        if(this.width_==-1||this.height_==-1)return j;
        return this.width_[db]()+"x"+this.height_[db]()
    }
    ;
    var br=function(a,b,c){
        var e=a.getContentUrl(),f=jq(e||"");
        c=kq(f,c||160);
        if(b)e=kq(f,b);
        ar[J](this,a.getTitle(),"photo",c,e||"");
        this.setDimensions(a.w,a.h);
        this.photo_=a
    }
    ;
    U(br,ar);
    br[y].getThumbnailUrl=function(a){
        return a?this.thumbnailUrl_||this.contentUrl_:kq(jq(this.contentUrl_),160,i)
    }
    ;
    br[y].getId=function(){
        return this.photo_.id||""
    }
    ;
    br[y].getAlbumId=function(){
        return this.photo_.getAlbumId()||""
    }
    ;
    var cr=function(a){
        var b=jq(a.getContentUrl()||"");
        b=kq(b,32,i);
        ar[J](this,a.getTitle(),"album",b,"");
        this.setCount(a.getCount());
        this.album_=a
    }
    ;
    U(cr,ar);
    cr[y].getFeed=function(){
        return this.album_.getFeed()
    }
    ;
    cr[y].getId=function(){
        return this.album_.id||""
    }
    ;
    var dr=function(a,b,c,e,f){
        qa(this,a);
        this.user=b;
        this.picker_=c;
        this.albumsFeed_=this.picker_.getUserFeed(b);
        this.photosFeed_=j;
        this.selectMode=e;
        this.view=f;
        this.gridViewMsgs_=[];
        this.element=j;
        this.eventHandler_=new jj(this);
        f&&f.setSource&&f.setSource(this);
        this.defineGridViewMsgs_()
    }
    ;
    Q=dr[y];
    Q.dm_=j;
    Q.setPhotosFeed=function(a){
        this.photosFeed_&&this.eventHandler_.unlisten(this.photosFeed_,"error",this.handleFeedError_);
        (this.photosFeed_=a)&&this.eventHandler_.listen(this.photosFeed_,"error",this.handleFeedError_)
    }
    ;
    Q.setAlbumsFeed=function(a){
        this.albumsFeed_&&this.eventHandler_.unlisten(this.albumsFeed_,"error",this.handleFeedError_);
        (this.albumsFeed_=a)&&this.eventHandler_.listen(this.albumsFeed_,"error",this.handleFeedError_)
    }
    ;
    Q.handleFeedError_=function(){
        this.picker_.setQueryInProgress(k);
        var a=this.picker_.getSelectedPanel();
        a.displayErrorMessage(this.picker_.getMsg("MSG_SCRIPT_LOAD_ERROR"))
    }
    ;
    Q.setUserId=function(a){
        this.user=a;
        this.setAlbumsFeed(this.picker_.getUserFeed(a))
    }
    ;
    Q.loadPhotos=function(a){
        this.photosFeed_?this.photosFeed_.loadAll(a):a(j,0,0)
    }
    ;
    Q.loadAlbums=function(a){
        this.albumsFeed_?this.albumsFeed_.loadAll(a):a(j,0,0)
    }
    ;
    Q.defineGridViewMsgs_=function(){
        this.gridViewMsgs_.getMsgPhotoCount=er;
        this.gridViewMsgs_.MSG_PHOTOS_BACK_LINK="&laquo;
Back to albums";
        this.gridViewMsgs_.MSG_PHOTO_COUNT="1 photo.";
        this.gridViewMsgs_.MSG_NO_IMAGES_FOUND="No Images Found.";
        this.gridViewMsgs_.MSG_PHOTOS_LOADING="Loading Photos.."
    }
    ;
    Q.getGridViewMsgs=function(){
        return this.gridViewMsgs_
    }
    ;
    var fr=function(a){
        if(a){
            a=a.getAllItems();
            a=Ne(a,function(b){
                return new cr(b)
            }
            )
        }
        else a=[];
        return a
    }
    ,gr=function(a,b){
        var c;
        if(a){
            c=a.getAllItems();
            var e=b.getConfigParam("imgmax"),f=b.getConfigParam("thumbsize"),g,h;
            if(f)g=fa(f);
            if(e)h=fa(e);
            c=Ne(c,function(n){
                return new br(n,h,g)
            }
            )
        }
        else c=[];
        return c
    }
    ;
    var hr=function(a){
        var b=a.getBooleanConfigParam("usernameShow"),c=a.getBooleanConfigParam("albumListSubShow");
        $q[J](this,a,b,c)
    }
    ;
    U(hr,$q);
    Q=hr[y];
    Q.msgCancelLabel="Cancel";
    Q.msgNoList="No public albums found.";
    Q.msgItemLabel="1 photo.";
    Q.msgListLoading="Loading Album List...";
    Q.getMsgTitle=function(){
        var a=this.picker_.getConfigParam("albumPaneTitle");
        if(a)return a;
        a=this.picker_.getUnescapedPhotoDisplayName();
        if(!a)return"Select an album";
        return a="Select a picture of "+a
    }
    ;
    Q.getMsgSubtitle=function(a){
        if(this.picker_.getConfigParam("newMessages"))return"";
        return a?this.picker_.getConfigParam("defaultAlbumSubtitle"):this.picker_.getConfigParam("defaultAlbumSubtitleNoUser")
    }
    ;
    Q.getMsgItemCount=function(a){
        return a=a+" photos."
    }
    ;
    Q.loadList_=function(){
        var a=this.picker_.getPicasaSource(),b=this.picker_,c;
        c=a[gc]?T(a[gc].sourcesChanged,a[gc]):T(this.sourcesChanged,this);
        a.loadAlbums(function(e){
            b.setContent(fr(e));
            c()
        }
        )
    }
    ;
    var ir=function(a){
        this.picker_=a;
        this.doc_=a.getDocument();
        this.eventHandler_=new jj(this);
        this.container_=this.makeCropView_();
        this.allowRectangular_=this.picker_.getConfigParam("rectangularCrop")==1;
        this.cropBoxTop_=24;
        this.cropBoxLeft_=48;
        this.previewSize_=64;
        this.aspectRatio_=this.picker_.getConfigParam("cropaspect");
        if(!this.picker_.getConfigParam("rectangularCrop"))this.aspectRatio_=1
    }
    ;
    ir[y].resizeMode_=k;
    ir[y].getContainer=function(){
        return this.container_
    }
    ;
    ir[y].dispose=function(){
        if(this.eventHandler_){
            this.eventHandler_.dispose();
            this.eventHandler_=j
        }
    }
    ;
    ir[y].makeCropView_=function(){
        var a=this.doc_[K]("div"),b=this.doc_[K]("table"),c=this.doc_[K]("tbody"),e=this.doc_[K]("tr"),f=this.doc_[K]("td");
        b[v](c);
        t(b,"mp_dialog");
        c[v](e);
        e[v](f);
        a[v](b);
        b=we(this.picker_.getUnescapedPhotoDisplayName(),75,i);
        b=this.picker_.isProfileMode()?"Crop this picture of yourself.":this.getMsgCropTitle(b);
        Wi(f,b);
        t(f,"mp_title");
        e=this.doc_[K]("tr");
        c[v](e);
        f=this.doc_[K]("td");
        e[v](f);
        t(f,"mp_middle");
        Xa(f,192);
        b=this.doc_[K]("p");
        f[v](b);
        e=this.doc_[K]("span");
        t(e,
        "mp_gray");
        Wi(e,"You can drag the box to select the crop area, and use the handle to resize it.");
        b[v](e);
        this.backLink_=this.doc_[K]("p");
        this.updateBackLink_();
        f[v](this.backLink_);
        e=this.doc_[K]("table");
        var g=this.doc_[K]("tbody"),h=this.doc_[K]("tr");
        b=this.doc_[K]("td");
        e[v](g);
        g[v](h);
        h[v](b);
        f[v](e);
        this.cropContainer_=this.doc_[K]("div");
        this.cropImage_=this.doc_[K]("img");
        Sa(this.cropImage_,0);
        this.cropImage_.onmousedown=function(){
            return k
        }
        ;
        this.cropContainer_[v](this.cropImage_);
        b[v](this.cropContainer_);
        this.cropFilter_=this.doc_[K]("div");
        t(this.cropFilter_,"mp_cropFilter");
        this.cropContainer_[v](this.cropFilter_);
        Pj(this.cropFilter_,0.7);
        this.cropBox_=this.doc_[K]("div");
        this.cropBox_.id="mp_crop_box";
        t(this.cropBox_,"mp_cropBox");
        this.cropContainer_[v](this.cropBox_);
        this.cropSubImage_=this.doc_[K]("img");
        Sa(this.cropSubImage_,0);
        this.cropBox_[v](this.cropSubImage_);
        this.growBoxImage_=this.doc_[K]("img");
        this.growBoxImage_.id="mp_crop_resize";
        t(this.growBoxImage_,"mp_cropResize");
        Sa(this.growBoxImage_,
        0);
        this.growBoxImage_.src=this.picker_.getImageUrl("GrowBox.gif");
        this.cropContainer_[v](this.growBoxImage_);
        b=this.doc_[K]("td");
        t(b,"mp_preview");
        h[v](b);
        e=this.doc_[K]("table");
        g=this.doc_[K]("tbody");
        h=this.doc_[K]("tr");
        f=this.doc_[K]("td");
        e[v](g);
        g[v](h);
        h[v](f);
        b[v](e);
        this.previewContainer_=this.doc_[K]("div");
        t(this.previewContainer_,"mp_previewContainer");
        this.previewImage_=this.doc_[K]("img");
        Sa(this.previewImage_,0);
        ta(this.previewImage_,128);
        Xa(this.previewImage_,96);
        this.previewImage_.onmousedown=
        function(){
            return k
        }
        ;
        this.previewContainer_[v](this.previewImage_);
        f[v](this.previewContainer_);
        h=this.doc_[K]("tr");
        g[v](h);
        f=this.doc_[K]("td");
        h[v](f);
        b=this.doc_[K]("span");
        t(b,"mp_previewLabel");
        Wi(b,"Preview");
        f[v](b);
        f.align="center";
        e=this.doc_[K]("tr");
        c[v](e);
        f=this.doc_[K]("td");
        e[v](f);
        t(f,"mp_buttons");
        this.submitButton_=this.doc_[K]("input");
        this.submitButton_.id="mp_submit_button";
        t(this.submitButton_,"mp_next");
        Oa(this.submitButton_,"button");
        za(this.submitButton_,this.picker_.getMsg("MSG_SUBMIT_CROP_LABEL"));
        f[v](this.submitButton_);
        this.eventHandler_.listen(this.submitButton_,"click",this.submitClicked_);
        this.cancelButton_=this.doc_[K]("input");
        this.cancelButton_.id="mp_cancel_button";
        Oa(this.cancelButton_,"submit");
        za(this.cancelButton_,"Cancel");
        f[v](this.cancelButton_);
        this.eventHandler_.listen(this.cancelButton_,"click",this.cancelClicked_);
        this.mouseDownHandler_=this.handleDragStart_[gd](this);
        this.resizeDragHandler_=this.handleResizeDragStart_[gd](this);
        this.loadHandler_=this.handleCropImageLoaded_[gd](this);
        this.eventHandler_.listen(this.cropBox_,"mousedown",this.mouseDownHandler_);
        this.eventHandler_.listen(this.growBoxImage_,"mousedown",this.resizeDragHandler_);
        this.eventHandler_.listen(this.cropImage_,"load",this.loadHandler_);
        return a
    }
    ;
    function _PP_GoBackG_(a){
        a.setGridView(a.cropView_.source_)
    }
    Hd("_PP_GoBackG_",_PP_GoBackG_,void 0);
    function _PP_GoBackU_(a){
        a.setUploadView()
    }
    Hd("_PP_GoBackU_",_PP_GoBackU_,void 0);
    function _PP_GoBackW_(a){
        a.setUrlView()
    }
    Hd("_PP_GoBackW_",_PP_GoBackW_,void 0);
    Q=ir[y];
    Q.updateBackLink_=function(){
        p.photopickerInstance=this.picker_;
        var a="",b="";
        if(this.returnView_==0){
            a="U";
            b=this.picker_.getMsg("MSG_UPLOAD_BACK_LINK")
        }
        else if(this.returnView_==2){
            a="G";
            b="&laquo;
Back to pictures"
        }
        else if(this.returnView_==8){
            a="W";
            b="&laquo;
Back to web address"
        }
        xa(this.backLink_,'<a href="javascript:_PP_GoBack'+a+'_(photopickerInstance);
">'+b+"</a>")
    }
    ;
    Q.setPhoto=function(a,b){
        if(this.photo_!=a){
            this.photo_=a;
            this.returnView_=b;
            this.updateBackLink_();
            this.cropImageSize_=a.calcDimensions(210,158,i);
            this.calcPreviewImageSize_(this.previewSize_,this.previewSize_);
            var c=this.picker_.getPlaceholderImageUrl();
            this.cropImage_.src=c;
            this.previewImage_.src=c;
            var e=a.getContentUrl();
            this.cropImage_.src=e;
            this.previewImage_.src=e;
            ta(this.cropImage_,this.cropImageSize_[z]);
            Xa(this.cropImage_,this.cropImageSize_[P]);
            ta(this.cropSubImage_,this.cropImageSize_[z]);
            Xa(this.cropSubImage_,this.cropImageSize_[P]);
            this.cropSubImage_.src=c;
            this.cropSubImage_.src=e;
            ta(this.cropFilter_[H],this.cropImageSize_[z]+1+"px");
            Xa(this.cropFilter_[H],this.cropImageSize_[P]+1+"px");
            this.cropBoxHeight_=this.cropBoxWidth_=r[ub](r.min(this.cropImageSize_[z]/2,this.cropImageSize_[P]/2));
            this.constrainCropBox_();
            this.centerCropBox_()
        }
    }
    ;
    Q.centerCropBox_=function(){
        this.cropBoxLeft_=(this.cropImageSize_[z]-this.cropBoxWidth_)/2;
        this.cropBoxTop_=(this.cropImageSize_[P]-this.cropBoxHeight_)/2;
        this.updateCropBoxPosition_()
    }
    ;
    Q.calcPreviewImageSize_=function(a,b){
        var c=r[ub](a*this.cropImageSize_[z]/this.cropBoxWidth_),e=r[ub](b*this.cropImageSize_[P]/this.cropBoxHeight_);
        this.previewImageSize_={
width:c,height:e
        }
        ;
        ta(this.previewImage_,c);
        Xa(this.previewImage_,e)
    }
    ;
    Q.constrain_=function(a,b,c,e){
        c=c-b[ec];
        e=e-b.top;
        var f=r.min(b[z],c),g=r.min(b[P],e);
        if(a>=1){
            g=f/a;
            if(g>e){
                g=e;
                f=g*a
            }
        }
        else{
            f=g*a;
            if(f>c){
                f=c;
                g=f/a
            }
        }
        return new vj(b[ec],b.top,f,g)
    }
    ;
    Q.updateCropBoxPosition_=function(){
        var a=Hj(this.cropContainer_),b=this.picker_.getDialog();
        b=Hj(b);
        a.x-=b.x;
        a.y-=b.y;
        Da(this.cropBox_[H],r[ub](a.x+this.cropBoxLeft_)+"px");
        this.cropBox_[H].top=r[ub](a.y+this.cropBoxTop_)+"px";
        var c=b=this.previewSize_;
        if(this.cropBoxWidth_){
            ta(this.cropBox_[H],this.cropBoxWidth_+"px");
            Xa(this.cropBox_[H],this.cropBoxHeight_+"px");
            if(this.allowRectangular_){
                var e=this.cropBoxWidth_/this.cropBoxHeight_;
                if(this.cropBoxWidth_>this.cropBoxHeight_)c=r[ub](b/e);
                else b=
                r[ub](c*e);
                ta(this.previewContainer_[H],b+"px");
                Xa(this.previewContainer_[H],c+"px")
            }
            this.calcPreviewImageSize_(b,c)
        }
        Da(this.cropFilter_[H],a.x+"px");
        this.cropFilter_[H].top=a.y+"px";
        b=r[ub](this.cropBoxLeft_*this.previewImageSize_[z]/this.cropImageSize_[z]);
        c=r[ub](this.cropBoxTop_*this.previewImageSize_[P]/this.cropImageSize_[P]);
        this.previewContainer_.scrollLeft=b;
        this.previewContainer_.scrollTop=c;
        if(this.cropBoxWidth_){
            Da(this.growBoxImage_[H],a.x+this.cropBoxLeft_+this.cropBoxWidth_+"px");
            this.growBoxImage_[H].top=
            a.y+this.cropBoxTop_+this.cropBoxHeight_+"px"
        }
        this.cropBox_.scrollTop=this.cropBoxTop_+2;
        this.cropBox_.scrollLeft=this.cropBoxLeft_+2
    }
    ;
    Q.getFraction_=function(a,b){
        return r[ub](a*100/b)/100
    }
    ;
    Q.getCropString=function(){
        var a=this.getFraction_(this.cropBoxLeft_,this.cropImageSize_[z]),b=this.getFraction_(this.cropBoxTop_,this.cropImageSize_[P]),c=this.getFraction_(this.cropBoxLeft_+this.cropBoxWidth_+2,this.cropImageSize_[z]),e=this.getFraction_(this.cropBoxTop_+this.cropBoxHeight_+2,this.cropImageSize_[P]);
        return a+","+b+","+c+","+e
    }
    ;
    Q.handleCropImageLoaded_=function(){
        this.updateCropBoxPosition_()
    }
    ;
    Q.activate=function(){
        this.cropImage_&&this.cropImageSize_&&this.updateCropBoxPosition_();
        this.disableButtons(k)
    }
    ;
    Q.handleDragStart_=function(a){
        var b=mg?a[Vb]+1:a[Vb];
        if(b>1)return k;
        this.initialPosition_={
x:a[Bd],y:a[Cd]
        }
        ;
        this.initialX_=this.cropBoxLeft_;
        this.initialY_=this.cropBoxTop_;
        this.moveHandler_=this.handleDragMove_[gd](this);
        this.upHandler_=this.handleDragEnd_[gd](this);
        this.outHandler_=this.handleDragOut_[gd](this);
        Y(this.doc_[dc],"mousemove",this.moveHandler_,k);
        Y(this.doc_[dc],"mouseup",this.upHandler_,k);
        Y(this.doc_[dc],"mouseout",this.outHandler_,k);
        a[Sb]();
        return k
    }
    ;
    Q.handleResizeDragStart_=function(a){
        this.resizeMode_=i;
        this.initialCropBoxWidth_=this.cropBoxWidth_;
        this.initialCropBoxHeight_=this.cropBoxHeight_;
        this.handleDragStart_(a)
    }
    ;
    Q.constrainCropBox_=function(){
        var a=this.cropImageSize_[z]-2,b=this.cropImageSize_[P]-2;
        if(this.aspectRatio_>0){
            var c=new vj(this.cropBoxLeft_,this.cropBoxTop_,this.cropBoxWidth_,this.cropBoxHeight_);
            b=this.constrain_(this.aspectRatio_,c,a,b);
            this.cropBoxWidth_=b[z];
            this.cropBoxHeight_=b[P]
        }
        else{
            a=a-this.cropBoxLeft_;
            b=b-this.cropBoxTop_;
            this.cropBoxWidth_=r.min(this.cropBoxWidth_,a);
            this.cropBoxHeight_=r.min(this.cropBoxHeight_,b)
        }
    }
    ;
    Q.handleDragMove_=function(a){
        var b={
x:a[Bd],y:a[Cd]
        }
        ,c=b.x-this.initialPosition_.x,e=b.y-this.initialPosition_.y;
        b=this.initialX_;
        var f=this.initialY_;
        if(this.resizeMode_){
            this.cropBoxWidth_=r.max(this.initialCropBoxWidth_+c,16);
            this.cropBoxHeight_=r.max(this.initialCropBoxHeight_+e,16);
            this.constrainCropBox_()
        }
        else{
            b+=c;
            f+=e;
            b=r.max(b,0);
            f=r.max(f,0);
            c=this.cropImageSize_[z]-this.cropBoxWidth_-2;
            e=this.cropImageSize_[P]-this.cropBoxHeight_-2;
            b=r.min(b,c);
            f=r.min(f,e)
        }
        this.cropBoxLeft_=b;
        this.cropBoxTop_=
        f;
        this.updateCropBoxPosition_();
        a[Sb]();
        return k
    }
    ;
    Q.handleDragEnd_=function(a){
        lh(this.doc_[dc],"mousemove",this.moveHandler_,k);
        lh(this.doc_[dc],"mouseup",this.upHandler_,k);
        lh(this.doc_[dc],"mouseout",this.outHandler_,k);
        this.resizeMode_=k;
        a[Sb]();
        return k
    }
    ;
    Q.handleDragOut_=function(a){
        a[nb]||a.toElement||this.handleDragEnd_(a)
    }
    ;
    Q.submitClicked_=function(){
        this.picker_.doneCrop(this.getCropString())
    }
    ;
    Q.cancelClicked_=function(){
        this.picker_.cancel();
        this.picker_.hide()
    }
    ;
    Q.disableButtons=function(a){
        Aa(this.submitButton_,a);
        Aa(this.cancelButton_,a)
    }
    ;
    Q.setSource=function(a){
        this.source_=a
    }
    ;
    Q.getMsgCropTitle=function(a){
        var b=this.picker_.getConfigParam("cropPaneTitle");
        if(b)return b;
        if(!a)return"Crop this picture";
        return a="Crop this picture of "+a
    }
    ;
    var jr=function(a){
        this.picker_=a;
        this.eventHandler_=new jj(this);
        this.container_=this.makeEvergreenView_()
    }
    ;
    Q=jr[y];
    Q.getContainer=function(){
        return this.container_
    }
    ;
    Q.activate=function(){
        this.disableButtons(k)
    }
    ;
    Q.dispose=function(){
        if(this.eventHandler_){
            this.eventHandler_.dispose();
            this.eventHandler_=j
        }
    }
    ;
    Q.makeEvergreenView_=function(){
        var a=this.picker_.getUnescapedPhotoDisplayName(),b=this.picker_.getBooleanConfigParam("profileMode"),c;
        if(b)c="You have selected the following picture.  You can accept this photo or upload another one.";
        else c=c=a+" has selected this picture. You can accept this photo or upload your own picture.";
        c=c;
        if(b)a="You haven't yet selected a picture, but you can upload one now.";
        else a=a=a+(" hasn't yet selected a picture. However, you can upload your own picture for "+(a+
        "."));
        a=a;
        b=b?"My Picture":"Their Picture";
        var e=new wi(this.doc_),f=e.createDom[gd](e,"div"),g=e.createDom[gd](e,"p"),h=e.createDom[gd](e,"img"),n=e.createDom[gd](e,"table"),o=e.createDom[gd](e,"tbody"),s=e.createDom[gd](e,"tr"),A=e.createDom[gd](e,"td");
        e=e.createDom[gd](e,"input");
        c=[s(j,A({
            "class":"mp_title"
        }
        ,b)),s({
        }
        ,A({
            "class":"mp_middle",height:"100%"
        }
        ,n({
        }
        ,o({
        }
        ,s({
        }
        ,A({
            "class":"mp_middle mp_leftcell"
        }
        ,this.image_=h({
        }
        )),A({
            "class":"mp_middle mp_rightcell"
        }
        ,g({
        }
        ,c))))))),s({
        }
        ,A({
            "class":"mp_buttons",
valign:"bottom"
        }
        ,this.cancelButton_=e({
type:"button",value:"Cancel"
        }
        ),this.submitButton_=e({
type:"submit",value:"Accept this picture"
        }
        )))];
        this.evergreenDiv_=f({
style:"display: none"
        }
        ,n({
            "class":"mp_dialog"
        }
        ,o({
        }
        ,c)));
        c=[s(j,A({
            "class":"mp_title"
        }
        ,b)),s({
        }
        ,A({
            "class":"mp_middle",height:"100%"
        }
        ,g({
        }
        ,a))),s({
        }
        ,A({
            "class":"mp_buttons",valign:"bottom"
        }
        ,this.cancelButton2_=e({
type:"button",value:"Cancel"
        }
        )))];
        this.noEvergreenDiv_=f({
style:"display: none"
        }
        ,n({
            "class":"mp_dialog"
        }
        ,o({
        }
        ,c)));
        this.eventHandler_.listen(this.cancelButton_,
        "click",this.cancelClicked_);
        this.eventHandler_.listen(this.cancelButton2_,"click",this.cancelClicked_);
        this.eventHandler_.listen(this.submitButton_,"click",this.submitClicked_);
        return f({
style:"height: 100%"
        }
        ,this.evergreenDiv_,this.noEvergreenDiv_)
    }
    ;
    Q.setPicture=function(a){
        this.showEvergreenPhoto_(k);
        this.photo_=new ar("Their picture","image/jpeg",a,a);
        this.photo_.measureImage(this.photoLoaded_[gd](this));
        this.image_.src=a
    }
    ;
    Q.photoLoaded_=function(){
        this.showEvergreenPhoto_(i)
    }
    ;
    Q.showEvergreenPhoto_=function(a){
        xj(this.evergreenDiv_,"display",a?"block":"none");
        xj(this.noEvergreenDiv_,"display",a?"none":"block")
    }
    ;
    Q.disableButtons=function(a){
        Aa(this.cancelButton_,a);
        Aa(this.cancelButton2_,a);
        Aa(this.submitButton_,a)
    }
    ;
    Q.cancelClicked_=function(){
        this.picker_.cancel();
        this.picker_.hide()
    }
    ;
    Q.submitClicked_=function(){
        this.picker_.setPhoto(this.photo_,2);
        this.picker_.doneEvergreen()
    }
    ;
    var kr=function(a,b,c,e,f,g,h,n,o){
        this.doc_=a;
        this.bodyImageURL_=b;
        this.indicatorImageURL_=c;
        this.bodyWidth_=e;
        this.rightOffset_=this.leftOffset_=0;
        this.callback_=n;
        this.doneCallback_=o;
        this.sliderContainer_=j;
        this.min_=f;
        this.max_=g;
        this.actualWidth_=this.bodyWidth_-this.leftOffset_-this.rightOffset_;
        this.startValue_=this.currentValue_=h;
        this.initialX_=0;
        this.render_()
    }
    ;
    Q=kr[y];
    Q.getSliderContainer=function(){
        return this.sliderContainer_
    }
    ;
    Q.render_=function(){
        this.sliderContainer_=this.doc_[K]("span");
        this.bodyImage_=this.doc_[K]("img");
        this.bodyImage_[Pc]("src",this.bodyImageURL_);
        this.bodyImage_[Pc]("width",this.bodyWidth_);
        this.indicatorContainer_=this.doc_[K]("div");
        this.indicatorImage_=this.doc_[K]("img");
        this.indicatorImage_[Pc]("src",this.indicatorImageURL_);
        this.indicatorImage_[Pc]("border","0");
        var a=X?"e-resize":"ew-resize";
        if(ng)a="move";
        var b=this.indicatorImage_;
        a="position:relative;
top:0px;
left:0px;
cursor:"+a;
        X?b[H][Pc]("cssText",
        a):b[Pc]("style",a);
        this.indicatorImage_[H].top="2px";
        this.sliderContainer_[v](this.bodyImage_);
        this.sliderContainer_[v](this.indicatorImage_);
        this.setIndicatorPosition()
    }
    ;
    Q.activate=function(){
        this.knobDragHandler_=this.handleDragStart_[gd](this);
        this.bodyClickHandler_=this.handleBodyClick_[gd](this);
        Y(this.indicatorImage_,"mousedown",this.knobDragHandler_,k);
        Y(this.bodyImage_,"click",this.bodyClickHandler_,k)
    }
    ;
    Q.handleDragStart_=function(a){
        var b=mg?a[Vb]+1:a[Vb];
        if(b>1)return k;
        this.initialX_=a[Bd]-this.rightOffset_;
        this.initialXPos_=da(this.indicatorImage_[H][ec],10);
        this.startValue_=this.currentValue_;
        this.basePosition_=Hj(this.sliderContainer_);
        this.moveHandler_=this.handleDragMove_[gd](this);
        this.upHandler_=this.handleDragEnd_[gd](this);
        this.outHandler_=this.handleMouseOut_[gd](this);
        Y(this.doc_[dc],"mousemove",this.moveHandler_,k);
        Y(this.doc_[dc],"mouseup",this.upHandler_,k);
        Y(this.doc_[dc],"mouseout",
        this.outHandler_,k);
        a[Sb]();
        return k
    }
    ;
    Q.handleDragMove_=function(a){
        var b=r[ub](this.indicatorImage_[z]/2),c=a[Bd]-this.basePosition_.x;
        if(c<this.actualWidth_/2)b=0;
        this.currentValue_=this.calcValueFromOffset_(c-b);
        this.setIndicatorPosition();
        this.callback_&&this.callback_(this.currentValue_);
        a[Sb]();
        return k
    }
    ;
    Q.handleDragEnd_=function(a){
        lh(this.doc_[dc],"mousemove",this.moveHandler_,k);
        lh(this.doc_[dc],"mouseup",this.upHandler_,k);
        lh(this.doc_[dc],"mouseout",this.outHandler_,k);
        this.doneCallback_&&this.doneCallback_(this.startValue_,this.currentValue_);
        a[Sb]();
        return k
    }
    ;
    Q.handleMouseOut_=function(a){
        a[nb]||a.toElement||this.handleDragEnd_(a)
    }
    ;
    Q.handleBodyClick_=function(a){
        this.basePosition_=Hj(this.sliderContainer_);
        return this.handleDragMove_(a)
    }
    ;
    Q.getIndicatorPosition=function(a){
        a=this.calcIndicatorOffset_(a);
        var b=r[ub](this.indicatorImage_[z]/2);
        return a-b-this.rightOffset_-this.actualWidth_
    }
    ;
    Q.setIndicatorPosition=function(){
        Da(this.indicatorImage_[H],this.getIndicatorPosition(this.currentValue_)+"px")
    }
    ;
    Q.getValue=function(){
        return this.currentValue_
    }
    ;
    Q.setValue=function(a,b){
        if(a!=this.currentValue_){
            this.currentValue_=a;
            this.setIndicatorPosition();
            this.callback_&&!b&&this.callback_(this.currentValue_)
        }
    }
    ;
    Q.calcIndicatorOffset_=function(a){
        return(a-this.min_)*this.actualWidth_/(this.max_-this.min_)
    }
    ;
    Q.calcValueFromOffset_=function(a){
        var b=r[ub](this.indicatorImage_[z]/2),c=this.max_-this.min_;
        a=this.min_+r[ub](c*(a-this.leftOffset_)/(this.actualWidth_-b));
        return r.max(r.min(a,this.max_),this.min_)
    }
    ;
    var lr=function(a){
        this.picker_=a;
        this.doc_=a.getDocument();
        this.selectedIndex_=-1;
        this.imageMap_=[];
        this.photoMap_=[];
        this.sliderContainer_=this.photoList_=this.selectedAlbum_=j;
        this.zoomIndex_=3;
        this.source_=j;
        this.eventHandler_=new jj(this);
        this.container_=this.makeGridContainer_();
        this.defaultAlbumOnly_=this.picker_.getConfigParam("defaultAlbumOnly");
        Hd("photopickerInstance",this.picker_,void 0)
    }
    ;
    Q=lr[y];
    Q.setDefaultAlbumOnly=function(a){
        this.defaultAlbumOnly_=a
    }
    ;
    Q.setAlbum=function(a){
        if(a!=this.selectedAlbum_){
            this.selectedAlbum_=a;
            this.selectedIndex_=-1;
            a&&delete this.photoList_;
            this.updateSubtitle_()
        }
    }
    ;
    Q.getAlbum=function(){
        return this.selectedAlbum_
    }
    ;
    Q.setPhotoList=function(a){
        this.photoList_=a
    }
    ;
    Q.clearPhotoList=function(){
        delete this.photoList_;
        this.photoList_=j
    }
    ;
    Q.adjustZoom_=function(a){
        this.zoomIndex_=a<3?2:a<9?4:a<16?5:a<24?6:7;
        this.slider_.setValue(100-this.zoomIndex_*10)
    }
    ;
    Q.activate=function(){
        this.photoList_||this.loadPhotoFeed_()
    }
    ;
    Q.getContainer=function(){
        return this.container_
    }
    ;
    Q.dispose=function(){
        if(this.eventHandler_){
            this.eventHandler_.dispose();
            this.eventHandler_=j
        }
    }
    ;
    Q.makeGridContainer_=function(){
        var a=this.picker_.getBooleanConfigParam("imagePickOnly"),b=this.picker_.getBooleanConfigParam("defaultAlbumOnly"),c=this.picker_.getUnescapedPhotoDisplayName(),e=this.doc_[K]("table"),f=this.doc_[K]("tbody"),g=this.doc_[K]("tr"),h=this.doc_[K]("td");
        e[v](f);
        t(e,"mp_dialog");
        f[v](g);
        g[v](h);
        if(g=!b||!a){
            g="";
            if(!this.picker_.getConfigParam("newMessages"))if(c)g=c="Select a picture of "+c;
            else g="Select a picture";
            Wi(h,this.picker_.isProfileMode()?"Select a picture of yourself":
            g);
            t(h,"mp_title");
            g=this.doc_[K]("tr");
            f[v](g);
            h=this.doc_[K]("td");
            g[v](h);
            t(h,"mp_middle");
            Xa(h,"100%");
            this.subTitle_=this.doc_[K]("p");
            h[v](this.subTitle_);
            this.updateSubtitle_()
        }
        this.thumbnailContainer_=this.doc_[K]("div");
        t(this.thumbnailContainer_,"mp_pictures"+this.picker_.getTheme());
        this.thumbnailContainer_.id="mp_pictures";
        this.addLoadingMessage_();
        this.eventHandler_.listen(this.thumbnailContainer_,"mousedown",this.mouseClicked_);
        this.gridContainer_=this.doc_[K]("div");
        t(this.gridContainer_,
        "mp_scroller"+this.picker_.getTheme());
        this.gridContainer_[v](this.thumbnailContainer_);
        h[v](this.gridContainer_);
        if(c=this.picker_.getConfigParam("albumPaneMsg")){
            this.msgContainer_=this.doc_[K]("div");
            t(this.msgContainer_,"mp_msg");
            h[v](this.msgContainer_);
            Wi(this.msgContainer_,c)
        }
        g=this.doc_[K]("tr");
        f[v](g);
        if(a){
            a=this.doc_[K]("td");
            g[v](a)
        }
        else{
            h=this.doc_[K]("td");
            g[v](h);
            t(h,"mp_buttons");
            g=this.doc_[K]("table");
            ta(g,"100%");
            b=this.doc_[K]("tbody");
            f=this.doc_[K]("tr");
            a=c=this.doc_[K]("td");
            h[v](g);
            g[v](b);
            b[v](f);
            f[v](c);
            h=this.doc_[K]("input");
            Oa(h,"submit");
            za(h,"Cancel");
            c[v](h);
            this.eventHandler_.listen(h,"click",this.cancelClicked_);
            c=this.doc_[K]("td");
            c.align="right";
            f[v](c)
        }
        h=this.doc_[K]("span");
        t(h,"mp_zoom");
        f=this.doc_[K]("span");
        t(f,"mp_gray");
        Wi(f,"Zoom:");
        c=Ni("&nbsp;
");
        f[v](c);
        h[v](f);
        f=this.zoomIndex_*10;
        this.slider_=new kr(this.doc_,this.picker_.getImageUrl("Track.gif"),this.picker_.getImageUrl("Knob.gif"),120,0,100,f,T(this.updateZoom_,this));
        h[v](this.slider_.getSliderContainer());
        this.sliderContainer_=h;
        a[v](h);
        this.slider_.activate();
        return e
    }
    ;
    function _PP_GoBack_(a){
        a.setView(a.getCurrentSource()[gc])
    }
    Hd("_PP_GoBack_",_PP_GoBack_,void 0);
    Q=lr[y];
    Q.updateSubtitle_=function(){
        var a=j;
        if(this.selectedAlbum_){
            a=this.selectedAlbum_.getCount();
            a=a==1?this.gridViewMsgs_.MSG_PHOTO_COUNT:this.gridViewMsgs_.getMsgPhotoCount(a);
            Qi(this.subTitle_);
            if(!this.defaultAlbumOnly_){
                var b=Ni('<a href="javascript:_PP_GoBack_(photopickerInstance);
" >'+this.gridViewMsgs_.MSG_PHOTOS_BACK_LINK+"</a>&nbsp;
&nbsp;
&nbsp;
");
                this.subTitle_[v](b)
            }
            b=q[Nb](this.selectedAlbum_.getTitle());
            this.subTitle_[v](b);
            a=Ni("&nbsp;
&nbsp;
<span class=mp_photocount>"+a+"</span>");
            this.subTitle_[v](a)
        }
    }
    ;
    Q.clearThumbnails_=function(){
        Qi(this.thumbnailContainer_)
    }
    ;
    Q.cancelClicked_=function(){
        this.picker_.cancel();
        this.picker_.hide()
    }
    ;
    Q.updateZoom_=function(a){
        this.setZoom(r[ub]((100-a)/10))
    }
    ;
    Q.calcThumbnailWidth_=function(){
        var a=Mj(this.thumbnailContainer_);
        return r[ub]((a[z]-16)/this.zoomIndex_)-12
    }
    ;
    Q.populateImageGrid_=function(){
        this.imageMap_=[];
        this.photoMap_=[];
        var a=this.photoList_,b=this.calcThumbnailWidth_();
        this.clearThumbnails_();
        for(var c=0;
        c<a[x];
        c++){
            var e=a[c],f=this.doc_[K]("img"),g=e.getAspectRatio();
            if(g==0)g=r[ub](b*3/4);
            else{
                g>1||(b=r[ub](b*g));
                g=r[ub](b/g)
            }
            f.src=e.getThumbnailUrl(0);
            ta(f,b);
            Xa(f,g);
            f.photoIndex=c;
            if(e.getTitle()!=j)qa(f,this.getToolTip_(e));
            this.thumbnailContainer_[v](f);
            this.imageMap_[w](f);
            this.photoMap_[w](e)
        }
        this.updateThumbnailSizes_();
        this.sliderContainer_&&
        Qj(this.sliderContainer_,a[x]>0)
    }
    ;
    Q.addLoadingMessage_=function(){
        if(this.picker_.isQueryInProgress()){
            var a=this.doc_[K]("div"),b=this.picker_.getSpinImageUrl();
            b=Ni("<br><br><br><center><font size=4 font color=#4D4D4D>"+this.gridViewMsgs_.MSG_PHOTOS_LOADING+'<img src="'+b+'" hspace=8></font></center>');
            a[v](b);
            this.thumbnailContainer_[v](a)
        }
    }
    ;
    Q.displayErrorMessage=function(a){
        Qi(this.thumbnailContainer_);
        var b=this.doc_[K]("div");
        a=Ni("<br><br><br><center><font size=4 font color=#cc0000>"+a+"</font></center>");
        b[v](a);
        this.thumbnailContainer_[v](b)
    }
    ;
    Q.getToolTip_=function(a){
        var b=a.getTitle();
        a=a.getDimensionsLabel();
        if(a!=j)b+=", "+a;
        return b
    }
    ;
    Q.updateThumbnailSizes_=function(){
        for(var a=this.calcThumbnailWidth_(),b=0;
        b<this.imageMap_[x];
        b++){
            var c=this.photoMap_[b],e=this.imageMap_[b];
            c=c.calcDimensions(a);
            ta(e,c[z]);
            Xa(e,c[P])
        }
    }
    ;
    Q.calcImageIndex_=function(a){
        for(var b=0;
        b<this.imageMap_[x];
        b++){
            var c=this.imageMap_[b],e=Hj(c);
            if(ng){
                e.x-=this.gridContainer_[Ic];
                e.y-=this.gridContainer_[bb]
            }
            c=Mj(c);
            if(a.x>=e.x&&a.y>=e.y&&a.x<e.x+c[z]&&a.y<e.y+c[P])return b
        }
        return j
    }
    ;
    Q.loadPhotoFeed_=function(){
        this.picker_.setQueryInProgress(i);
        this.clearThumbnails_();
        this.addLoadingMessage_();
        var a=this.picker_.getPicasaSource(),b=this.picker_.getCurrentSource();
        b==a?this.loadPicasaFeed_(a):this.loadNonPicasaFeed_(b)
    }
    ;
    Q.loadNonPicasaFeed_=function(a){
        var b=this.picker_.getConfigParam("defaultAlbumFeedUrl");
        if(b)a=b;
        else if(this.selectedAlbum_!=j){
            a=this.selectedAlbum_.getContentUrl();
            if(a==j)return
        }
        else a=a.getUrl();
        a=this.picker_.appendExtraUrlParams(a||"");
        this.picker_.fetchJSONData(a,1)
    }
    ;
    Q.loadPicasaFeed_=function(a){
        a.loadPhotos(T(function(b,c,e){
            this.photoList_=b&&e?gr(b,this.picker_):[];
            this.picker_.setQueryInProgress(k);
            if(e<1||this.photoList_[x]<1){
                this.displayErrorMessage(this.gridViewMsgs_.MSG_NO_IMAGES_FOUND);
                this.sliderContainer_&&Qj(this.sliderContainer_,k)
            }
            else this.sourcesChanged()
        }
        ,this))
    }
    ;
    Q.mouseClicked_=function(a){
        if(this.picker_.isQueryInProgress())return k;
        a=a[I]&&typeof a[I].photoIndex=="number"?a[I].photoIndex:this.getSelectIndexFromPosition_(a);
        if(Pd(a)){
            a=this.photoMap_[a];
            var b=this.picker_.getBooleanConfigParam("cropEnabled");
            b&&this.picker_.setCropView(this.source_);
            this.picker_.setPhoto(a,2);
            b||this.picker_.doneSelect()
        }
        return i
    }
    ;
    Q.getSelectIndexFromPosition_=function(a){
        a={
x:a[Bd],y:a[Cd]
        }
        ;
        var b=Hi();
        a.x+=b.x;
        a.y+=b.y;
        return this.calcImageIndex_(a)
    }
    ;
    Q.setZoom=function(a){
        if(a<1)a=1;
        if(this.zoomIndex_!=a){
            this.zoomIndex_=a;
            this.updateThumbnailSizes_()
        }
    }
    ;
    Q.sourcesChanged=function(){
        this.adjustZoom_(this.photoList_[x]);
        this.populateImageGrid_();
        this.updateSubtitle_()
    }
    ;
    Q.setSource=function(a){
        this.source_=a;
        this.gridViewMsgs_=a.getGridViewMsgs()
    }
    ;
    var er=function(a){
        return a=a+" photos."
    }
    ;
    var mr=function(a,b){
        this.picker_=a;
        this.imageUrl_=b;
        this.eventHandler_=new jj(this);
        this.container_=this.makeNoPhotoView_()
    }
    ;
    Q=mr[y];
    Q.getContainer=function(){
        return this.container_
    }
    ;
    Q.activate=function(){
        this.disableButtons(k)
    }
    ;
    Q.dispose=function(){
        if(this.eventHandler_){
            this.eventHandler_.dispose();
            this.eventHandler_=j
        }
    }
    ;
    Q.makeNoPhotoView_=function(){
        var a=new wi(this.doc_),b=a.createDom[gd](a,"div"),c=a.createDom[gd](a,"p"),e=a.createDom[gd](a,"img"),f=a.createDom[gd](a,"table"),g=a.createDom[gd](a,"tbody"),h=a.createDom[gd](a,"tr"),n=a.createDom[gd](a,"td");
        a=a.createDom[gd](a,"input");
        if(!this.imageUrl_)return b({
        }
        );
        c=[h({
        }
        ,n({
            "class":"mp_title"
        }
        ,"No Picture")),h({
        }
        ,n({
            "class":"mp_middle",height:"100%"
        }
        ,f({
        }
        ,g({
        }
        ,h({
        }
        ,n({
            "class":"mp_middle mp_leftcell"
        }
        ,e({
src:this.imageUrl_
        }
        )),n({
            "class":"mp_middle mp_rightcell"
        }
        ,
        c({
        }
        ,"Show this default picture."))))))),h({
        }
        ,n({
            "class":"mp_buttons",valign:"bottom"
        }
        ,this.cancelButton_=a({
type:"button",value:"Cancel"
        }
        ),this.submitButton_=a({
type:"submit",value:"Apply Changes"
        }
        )))];
        this.eventHandler_.listen(this.cancelButton_,"click",this.cancelClicked_);
        this.eventHandler_.listen(this.submitButton_,"click",this.submitClicked_);
        return b({
style:"height: 100%"
        }
        ,f({
            "class":"mp_dialog"
        }
        ,g({
        }
        ,c)))
    }
    ;
    Q.disableButtons=function(a){
        Aa(this.submitButton_,a);
        Aa(this.cancelButton_,a)
    }
    ;
    Q.cancelClicked_=function(){
        this.picker_.cancel();
        this.picker_.hide()
    }
    ;
    Q.submitClicked_=function(){
        this.picker_.setPhoto(j,2);
        this.picker_.doneNoPhoto()
    }
    ;
    var nr={
getDimensionsLabel:function(){
            if(!this.w&&this.h)return j;
            return this.w+"x"+this.h
        }
        ,calcDimensions:function(a,b,c){
            var e=a;
            var f=b=b||a;
            c=c?this.getAspectRatio():1;
            if(c>1)f=r[ub](e/c);
            else if(c>0)e=r[ub](f*c);
            if(e>a){
                f=r[ub](f*a/e);
                e=a
            }
            if(f>b){
                e=r[ub](e*b/f);
                f=b
            }
            return{
width:e,height:f
            }
        }
    }
    ,or=function(a){
        mf(a,nr)
    }
    ;
    var pr={
        MSG_SCRIPT_LOAD_ERROR:"No images found.",MSG_PANEL_CHOOSE:"Choose a picture from:",MSG_SUBMIT_CROP_LABEL:"Apply Changes",MSG_UPLOAD_BACK_LINK:"&laquo;
Back to upload",MSG_URL_LABEL:"Image URL",MSG_URL_INSTRUCTIONS:"Type the image URL in the text field above. If it's correct, you'll see an image preview here.  Large images may take a while to appear.",MSG_URL_CAVEAT:"Remember, using others' images on the web without their permission may be bad manners or worse, copyright infringement.",MSG_SELECT_URL_LABEL:"Select Image",
        MSG_UPLOAD_TITLE:"Upload a picture of yourself",MSG_UPLOAD_STORAGE_INFO:"This photo will be available to view and share in Picasa Web Albums, Google's free photo hosting service. Go to: http://picasaweb.google.com to see it now and start sharing!",MSG_UPLOAD_STORAGE_INFO_GP:"This photo will be available to view and share in Google Photos, Google's free photo hosting service. Go to: http://photos.google.com to see it now and start sharing!",MSG_UPLOAD_FEEDBACK:"Uploading Image...",MSG_UPLOAD_BUTTON_LABEL:"Upload Picture"
    }
    ;
    var qr=function(a,b,c,e,f,g){
        qa(this,a);
        this.user=b;
        this.format=c;
        this.url=e;
        this.selectMode=f;
        this.view=g;
        this.gridViewMsgs=[];
        this.element=j;
        g!=j&&g.setSource&&g.setSource(this);
        this.defineGridViewMsgs_();
        this.albums_=j
    }
    ;
    Q=qr[y];
    Q.setUserId=function(a){
        return this.user=a
    }
    ;
    Q.getUrl=function(){
        if(!this.url)return j;
        return this.url[B](/<userId>/,this.user)
    }
    ;
    Q.fetchLink=function(a,b){
        for(var c=0;
        c<a[x];
        c++){
            var e=a[c];
            if(e.rel==b)return e[Rc]
        }
        return j
    }
    ;
    Q.extractAlbums=function(a){
        var b=[];
        a=a.feed.entry;
        if(!a)return b;
        for(var c=0;
        c<a[x];
        c++){
            var e=a[c],f=new Sh(this.fetchLink(e.link,"http://schemas.google.com/g/2005#feed")),g=e[mc].thumbnail[0].url;
            f.setParameterValue("alt","jsonm");
            f.setParameterValue("kind","photo");
            f.setParameterValue("thumbsize","160");
            f=new ar(e[ib],"container/photos",g,f[db]());
            f.setCount(e.numPhotos);
            f.setDescription(e.summary);
            f.setId(e.albumId);
            b[w](f)
        }
        return this.albums_=b
    }
    ;
    Q.extractPhotos=function(a,b){
        var c=[],e=a.feed.entry;
        if(!e)return c;
        if(e)for(var f=0;
        f<e[x];
        f++){
            var g=e[f],h=g.content$src,n=g[mc].thumbnail[0].url;
            n=n[Fb]("?")[0];
            h=new ar(g[ib],g.content$type,n,h);
            h.setDimensions(g[z],g[P]);
            c[w](h);
            b&&b.addItem(h)
        }
        return c
    }
    ;
    Q.defineGridViewMsgs_=function(){
        this.gridViewMsgs.getMsgPhotoCount=er;
        this.gridViewMsgs.MSG_PHOTOS_BACK_LINK="&laquo;
Back to albums";
        this.gridViewMsgs.MSG_PHOTO_COUNT="1 photo.";
        this.gridViewMsgs.MSG_NO_IMAGES_FOUND="No Images Found.";
        this.gridViewMsgs.MSG_PHOTOS_LOADING="Loading Photos.."
    }
    ;
    Q.getGridViewMsgs=function(){
        return this.gridViewMsgs
    }
    ;
    var rr=function(a){
        this.picker_=a;
        this.doc_=a.getDocument();
        this.eventHandler_=new jj(this);
        this.container_=this.makeSourcePanel_();
        this[ed]();
        this.show()
    }
    ;
    Q=rr[y];
    Q.selectedSource_=j;
    Q.getContainer=function(){
        return this.container_
    }
    ;
    Q.show=function(){
        var a=ng?"inline":"";
        Wa(this.container_[H],a)
    }
    ;
    Q.hide=function(){
        Wa(this.container_[H],"none")
    }
    ;
    Ta(Q,function(){
        var a=function(b){
            return!b.label_
        }
        ;
        a=Me(this.picker_.getSourceList(),a);
        this.selectSource(a[0])
    }
    );
    Q.dispose=function(){
        if(this.eventHandler_){
            this.eventHandler_.dispose();
            this.eventHandler_=j
        }
    }
    ;
    Q.selectSource=function(a){
        if(this.selectedSource_!=a){
            if(this.selectedSource_!=j)t(this.selectedSource_.element,"mp_unselected");
            t(a.element,"mp_selected");
            this.selectedSource_=a;
            this.picker_.setCurrentSource(a);
            return i
        }
        return k
    }
    ;
    Q.makeSourcePanel_=function(){
        var a=this.doc_[K]("table");
        t(a,"mp_sourcePanel"+this.picker_.getTheme());
        var b=this.doc_[K]("tbody");
        a[v](b);
        for(var c=this.picker_.getSourceList(),e=0;
        e<c[x];
        e++){
            var f=c[e],g=this.doc_[K]("tr");
            b[v](g);
            var h=this.doc_[K]("td");
            t(h,f.label_?"mp_sourcePanel_title":"mp_unselected");
            Wa(h[H],"block");
            if(f.selectMode!=j)h.id="mp_sourcePanel_"+f.selectMode;
            g[v](h);
            f.element=h;
            Wi(h,f[ib]);
            f.label_||this.eventHandler_.listen(h,"click",this.sourceClicked_[gd](this,f))
        }
        g=this.doc_[K]("tr");
        b[v](g);
        h=this.doc_[K]("td");
        g[v](h);
        Xa(h,"100%");
        t(h,"mp_sourcePanel_spacer");
        return a
    }
    ;
    Q.sourceClicked_=function(a){
        this.selectSource(a)&&this.picker_.setView(a[gc])
    }
    ;
    var sr=function(a){
        qa(this,a);
        this.label_=i
    }
    ;
    var tr=function(a){
        this.picker_=a;
        this.doc_=a.getDocument();
        this.eventHandler_=new jj(this);
        this.container_=this.makeSuggestView_()
    }
    ;
    Q=tr[y];
    Q.getContainer=function(){
        return this.container_
    }
    ;
    Q.activate=function(){
        this.disableButtons(k)
    }
    ;
    Q.dispose=function(){
        if(this.eventHandler_){
            this.eventHandler_.dispose();
            this.eventHandler_=j
        }
    }
    ;
    Q.setImageUrl=function(a){
        this.previewImage_.src=a
    }
    ;
    Q.makeSuggestView_=function(){
        var a=this.picker_.getUnescapedPhotoDisplayName(),b=ur(a),c=vr(a),e=wr(a),f=this.picker_.getPlaceholderImageUrl(),g=new wi(this.doc_);
        a=g.createDom[gd](g,"table");
        var h=g.createDom[gd](g,"tbody"),n=g.createDom[gd](g,"tr"),o=g.createDom[gd](g,"td"),s=g.createDom[gd](g,"p");
        g.createDom[gd](g,"a");
        var A=g.createDom[gd](g,"div"),G=g.createDom[gd](g,"textarea"),R=g.createDom[gd](g,"input");
        g=g.createDom[gd](g,"img");
        b=[o({
            "class":"mp_title"
        }
        ,b),o({
            "class":"mp_middle"
        }
        ,s({
        }
        ,
        c)),o({
            "class":"mp_middle",style:"height: 100%"
        }
        ,a({
width:"100%"
        }
        ,h({
        }
        ,n({
        }
        ,o({
            "class":"mp_middle mp_leftcell"
        }
        ,this.previewImage_=g({
            "class":"mp_suggestPreviewImage",src:f
        }
        )),o({
            "class":"mp_middle mp_rightcell",width:"100%"
        }
        ,this.textArea_=G({
            "class":"mp_suggestTextarea"
        }
        ,e)))))),o({
            "class":"mp_buttons"
        }
        ,this.submitButton_=R({
type:"submit",value:"Yes, suggest this picture"
        }
        ),this.cancelButton_=R({
type:"submit",value:"No, keep this picture to myself"
        }
        ))];
        this.eventHandler_.listen(this.submitButton_,
        "click",this.submitHandler_);
        this.eventHandler_.listen(this.cancelButton_,"click",this.cancelHandler_);
        return A({
style:"height: 100%"
        }
        ,a({
            "class":"mp_dialog",style:"height: 100%"
        }
        ,h({
        }
        ,Ne(b,function(L){
            return n({
            }
            ,L)
        }
        ))))
    }
    ;
    Q.submitHandler_=function(){
        this.picker_.doneSuggest(this.textArea_[D]);
        return i
    }
    ;
    Q.cancelHandler_=function(){
        this.picker_.doneSuggest("");
        return i
    }
    ;
    var ur=function(a){
        return a="Suggest this picture to "+(a+"?")
    }
    ,vr=function(a){
        return a="Would you like to suggest that "+(a+" uses this picture? If so, you can send the picture suggestion along with a custom message below.")
    }
    ,wr=function(a){
        return a="Hey "+(a+", I found this great picture for you!")
    }
    ;
    tr[y].disableButtons=function(a){
        Aa(this.submitButton_,a);
        Aa(this.cancelButton_,a)
    }
    ;
    var xr=function(a,b){
        this.picker_=a;
        this.doc_=a.getDocument();
        this.uploadURL_=b;
        this.eventHandler_=new jj(this);
        this.container_=this.makeUploadView_();
        this.jsonp_=j;
        this.albumItems_=[]
    }
    ;
    Q=xr[y];
    Q.uploadSelectorElement_=j;
    Q.aidField_=j;
    Q.getContainer=function(){
        return this.container_
    }
    ;
    Q.activate=function(){
        Wa(this.uploadHint_[H],"none");
        Wa(this.uploadFeedback_[H],"none");
        var a=this.doc_[Ib]("mp_upload_form");
        a[ed]();
        this.useUploadSelector_()&&this.loadAlbums_();
        try{
            this.fileElement_[zc]()
        }
        catch(b){
        }
    }
    ;
    Ta(Q,function(){
        var a=this.doc_[Ib]("mp_upload_form");
        a[ed]()
    }
    );
    Q.dispose=function(){
        if(this.eventHandler_){
            this.eventHandler_.dispose();
            this.eventHandler_=j
        }
    }
    ;
    Q.addHiddenField_=function(a,b,c){
        b=Ni('<input type="hidden" name="'+se(b)+'" value="'+se(c)+'"></input>');
        a[v](b);
        return b
    }
    ;
    Q.addExtraParams_=function(a){
        var b=this.picker_.getConfigParam("extraUploadParams"),c=this.picker_.getConfigParam("extraPicasaWebParams");
        if(c){
            if(b)b+=";
";
            b+=c
        }
        c=k;
        if(b){
            b=b[Fb](";
");
            for(var e=0;
            e<b[x];
            e++){
                var f=b[e];
                f=f[Fb]("=");
                if(f[x]==2){
                    var g=f[0];
                    this.addHiddenField_(a,g,f[1]);
                    c=c||"tok"==g
                }
            }
        }
        if(!c)(c=this.picker_.getConfigParam("tok"))&&this.addHiddenField_(a,"tok",c)
    }
    ;
    Q.makeUploadView_=function(){
        var a=this.doc_[K]("div");
        Xa(a[H],"100%");
        xa(a,'<FORM id="mp_upload_form" method="POST" enctype="multipart/form-data" style="height:100%" onsubmit="return false;
"></FORM>');
        this.form_=a[xd]("form")[0];
        this.addExtraParams_(this.form_);
        this.addHiddenField_(this.form_,"username",this.picker_.getConfigParam("userId"));
        a=this.doc_[K]("table");
        var b=this.doc_[K]("tbody"),c=this.doc_[K]("tr"),e=this.doc_[K]("td");
        a[v](b);
        t(a,"mp_dialog");
        b[v](c);
        c[v](e);
        if(c=this.picker_.getBooleanConfigParam("showUploadTitle")){
            c=
            this.picker_.isProfileMode();
            var f="";
            if(!this.picker_.getConfigParam("newMessages")){
                f=this.picker_.getUnescapedPhotoDisplayName();
                if(c)c=this.picker_.getMsg("MSG_UPLOAD_TITLE");
                else if(f)c=c="Upload a picture of "+f;
                else c="Upload a picture";
                f=c
            }
            Wi(e,f);
            t(e,"mp_title")
        }
        if(this.useUploadSelector_()){
            c=this.doc_[K]("tr");
            b[v](c);
            e=this.doc_[K]("td");
            c[v](e);
            t(e,"mp_middle");
            e[v](this.makeUploadSelector_())
        }
        c=this.doc_[K]("tr");
        b[v](c);
        e=this.doc_[K]("td");
        t(e,"mp_middle");
        c[v](e);
        Xa(e,"100%");
        c=this.doc_[K]("p");
        this.fileElement_=this.doc_[K]("input");
        Ua(this.fileElement_,this.picker_.getConfigParam("postFilename"));
        this.fileElement_.id="mp_file_element";
        Oa(this.fileElement_,"file");
        this.fileElement_.size=32;
        c[v](this.fileElement_);
        e[v](c);
        this.eventHandler_.listen(this.fileElement_,"change",this.fileAcquired_);
        c=this.doc_[K]("p");
        t(c,"mp_uploadInfo");
        f="You can upload a JPG, GIF, or PNG file.&nbsp;
(Do not upload pictures containing celebrities, nudity, artwork or copyrighted images.)";
        if(this.picker_.isProfileMode())f+=
        "<br/><br/>Note: The photo you specify here will be used across all Google products and services which display your public photo.";
        xa(c,f);
        e[v](c);
        this.uploadHint_=this.doc_[K]("p");
        this.uploadHint_.id="mp_upload_hint";
        Wa(this.uploadHint_[H],"none");
        e[v](this.uploadHint_);
        this.uploadFeedback_=this.doc_[K]("p");
        c=this.picker_.getSpinImageUrl();
        xa(this.uploadFeedback_,"<br><br><span class=mp_uploadFeedback>"+se(this.picker_.getMsg("MSG_UPLOAD_FEEDBACK"))+'&nbsp;
&nbsp;
</span><img src="'+c+'"/>');
        this.uploadFeedback_.id=
        "mp_upload_feedback";
        Wa(this.uploadFeedback_[H],"none");
        e[v](this.uploadFeedback_);
        c=this.doc_[K]("tr");
        b[v](c);
        this.buttonCell_=this.doc_[K]("td");
        c[v](this.buttonCell_);
        t(this.buttonCell_,"mp_buttons");
        c.valign="bottom";
        b=this.doc_[K]("input");
        Oa(b,"button");
        za(b,"Cancel");
        this.buttonCell_[v](b);
        this.eventHandler_.listen(b,"click",this.cancelClicked_);
        this.uploadButton_=this.doc_[K]("input");
        t(this.uploadButton_,"mp_next");
        Oa(this.uploadButton_,"button");
        Wa(this.uploadButton_[H],"none");
        za(this.uploadButton_,
        this.picker_.getMsg("MSG_UPLOAD_BUTTON_LABEL"));
        this.buttonCell_[v](this.uploadButton_);
        this.eventHandler_.listen(this.uploadButton_,"click",this.submitClicked_);
        this.form_[v](a);
        return this.form_
    }
    ;
    Q.updateDestinationAlbum_=function(){
        if(!this.aidField_){
            for(var a=this.form_[xd]("input"),b,c=0;
            b=a[c];
            c++)if(b.form==this.form_&&b[N]=="aid"){
                this.aidField_=b;
                break
            }
            if(!this.aidField_)this.aidField_=this.addHiddenField_(this.form_,"aid","-1")
        }
        za(this.aidField_,this.useUploadSelector_()?this.uploadAlbumMenu_[D]||"-1":"-1")
    }
    ;
    Q.fileAcquired_=function(){
        var a=this.fileElement_[D];
        if(a)if(this.picker_.isImage(a)){
            this.updateDestinationAlbum_();
            if(this.picker_.getBooleanConfigParam("autoLoad")){
                Wa(this.uploadHint_[H],"none");
                Wa(this.uploadFeedback_[H],"inline");
                this.uploadFile_()
            }
            else{
                Wa(this.uploadButton_[H],"");
                xa(this.uploadHint_,"<br><br>Click the Upload Picture button below to upload the selected image.");
                t(this.uploadHint_,"");
                Wa(this.uploadHint_[H],"none")
            }
        }
        else this.showError_("The file you selected is not a valid image file.  Please select another file.");
        else Qj(this.uploadButton_,k)
    }
    ;
    Q.displayErrorMessage=function(a){
        this.showError_(a)
    }
    ;
    Q.showError_=function(a){
        Wa(this.uploadButton_[H],"none");
        Wa(this.uploadHint_[H],"");
        t(this.uploadHint_,"mp_uploadError");
        xa(this.uploadHint_,"<br>"+se(a))
    }
    ;
    Q.uploadFile_=function(){
        var a=new Pp;
        this.eventHandler_.listen(a,"complete",this.fileUploadCompleted_[gd](this,a));
        a.sendFromForm(this.form_,this.uploadURL_)
    }
    ;
    Q.fileUploadCompleted_=function(a){
        Wa(this.uploadFeedback_[H],"none");
        var b;
        try{
            b=wh(a.getResponseText());
            if(!b||b.Success===ba)b={
Success:k
            }
        }
        catch(c){
            b={
Success:k
            }
        }
        if(a=b.Success){
            a=b.Body.imageId;
            var e=b.Body.imageUrl,f=b.Body.thumbnailUrl||e;
            b=b.Body.mimeType;
            b=new ar(a,b,f,e);
            b.measureImage(this.finishUpload_[gd](this,b))
        }
        else{
            this.showError_(b.Message||"The file you selected could not be uploaded. It may be too large or it was not a valid image file. Please select another file or click the upload button to try again.");
            Qj(this.uploadButton_,i)
        }
    }
    ;
    Q.finishUpload_=function(a){
        this.picker_.setPhoto(a,0);
        this.picker_.uploadComplete();
        this.picker_.getBooleanConfigParam("cropEnabled")?this.picker_.setCropView():this.picker_.doneSelect()
    }
    ;
    Q.useUploadSelector_=function(){
        return this.picker_.getBooleanConfigParam("uploadAlbumSelect")&&!!this.picker_.getUserId()
    }
    ;
    Q.loadAlbums_=function(){
        this.picker_.getAlbums(this.albumsChanged[gd](this))
    }
    ;
    Q.makeUploadSelector_=function(){
        this.uploadSelectorElement_=this.doc_[K]("div");
        Wi(this.uploadSelectorElement_,"Select Upload Album: ");
        this.uploadAlbumMenu_=this.doc_[K]("select");
        this.uploadSelectorElement_[v](this.uploadAlbumMenu_);
        Qj(this.uploadSelectorElement_,k);
        this.eventHandler_.listen(this.uploadAlbumMenu_,"change",this.updateDestinationAlbum_);
        return this.uploadSelectorElement_
    }
    ;
    Q.albumsChanged=function(a){
        if(!a||a[x]<1)Qj(this.uploadSelectorElement_,k);
        else{
            if(a[x]==1)if(this.picker_.isDefaultAlbum(a[0])){
                Qj(this.uploadSelectorElement_,k);
                return
            }
            var b=this.picker_.getConfigParam("defaultUploadAlbum"),c=-1,e=this.picker_.getConfigParam("extraAlbum"),f="",g="";
            if(e&&e[E](",")>0){
                g=e[Fb](",");
                f=g[0];
                g=g[1]
            }
            pa(this.uploadAlbumMenu_[tc],0);
            var h=k;
            e=0;
            var n=30,o=k;
            if(b){
                for(var s=0;
                s<a[x];
                s++){
                    var A=a[s],G=A.getTitle();
                    if(G==b){
                        h=i;
                        c=s;
                        break
                    }
                }
                if(!h&&f==b){
                    h=i;
                    c=0;
                    this.uploadAlbumMenu_[tc][e]=
                    new Option(we(f,n,o),g,h,h);
                    f="";
                    ++e
                }
            }
            for(s=0;
            s<a[x];
            s++){
                A=a[s];
                G=A.getTitle();
                A=A.getId();
                h=G==b;
                this.uploadAlbumMenu_[tc][e]=new Option(we(G,n,o),A,h,h);
                ++e;
                if(h)c=s;
                if(G==f)f=""
            }
            if(f){
                h=f==b;
                this.uploadAlbumMenu_[tc][this.uploadAlbumMenu_[tc][x]]=new Option(we(f,n,o),g,h,h);
                if(h)c=a[x]
            }
            if(c>=0)sa(this.uploadAlbumMenu_,c);
            Qj(this.uploadSelectorElement_,i)
        }
    }
    ;
    Q.submitClicked_=function(){
        Wa(this.uploadHint_[H],"none");
        Wa(this.uploadFeedback_[H],"inline");
        this.uploadFile_();
        return k
    }
    ;
    Q.cancelClicked_=function(){
        this.picker_.cancel();
        this.picker_.hide()
    }
    ;
    Hd("photopickerUploadComplete",xr.fileUploadCompleted_,void 0);
    Hd("photopickerUploadView",xr.uploadView_,void 0);
    var yr=function(a){
        this.picker_=a;
        this.doc_=a.getDocument();
        this.eventHandler_=new jj(this);
        this.container_=this.makeUrlView_();
        this.delay_=new Yq(this.checkUrl_,1E3,this)
    }
    ;
    Q=yr[y];
    Q.inputHandler_=j;
    Q.getContainer=function(){
        return this.container_
    }
    ;
    Q.activate=function(){
        try{
            this.urlInput_[zc]()
        }
        catch(a){
        }
    }
    ;
    Q.dispose=function(){
        if(this.eventHandler_){
            this.eventHandler_.dispose();
            this.eventHandler_=j
        }
        this.delay_.dispose()
    }
    ;
    Q.makeUrlView_=function(){
        var a=this.doc_[K]("div");
        Xa(a[H],"100%");
        var b=this.doc_[K]("table"),c=this.doc_[K]("tbody"),e=this.doc_[K]("tr"),f=this.doc_[K]("td");
        b[v](c);
        t(b,"mp_dialog");
        c[v](e);
        e[v](f);
        a[v](b);
        b=this.picker_.getBooleanConfigParam("profileMode");
        e="";
        if(!this.picker_.getConfigParam("newMessages")){
            if(b)b="Specify an Image URL";
            else if(b=this.picker_.getUnescapedPhotoDisplayName())b=b="Image URL for "+b;
            else b="Image URL";
            e=b
        }
        Wi(f,e);
        t(f,"mp_title");
        e=this.doc_[K]("tr");
        c[v](e);
        f=
        this.doc_[K]("td");
        t(f,"mp_middle");
        e[v](f);
        b=this.doc_[K]("span");
        Wi(b,this.picker_.getMsg("MSG_URL_LABEL"));
        t(b,"mp_url_label");
        f[v](b);
        this.urlInput_=this.doc_[K]("input");
        this.urlInput_.id="mp_url_input";
        Oa(this.urlInput_,"text");
        this.urlInput_.size="30";
        f[v](this.urlInput_);
        this.inputHandler_=new Zq(this.urlInput_);
        this.inputHandler_[Lc]("input",this.handleInput_,i,this);
        e=this.doc_[K]("tr");
        c[v](e);
        f=this.doc_[K]("td");
        Xa(f,100);
        ta(f,340);
        e[v](f);
        this.imagePreview_=this.doc_[K]("img");
        this.imagePreview_.id=
        "mp_preview_image";
        t(this.imagePreview_,"mp_preview_image");
        Qj(this.imagePreview_,k);
        f[v](this.imagePreview_);
        this.imagePrompt_=this.doc_[K]("div");
        Wi(this.imagePrompt_,this.picker_.getMsg("MSG_URL_INSTRUCTIONS"));
        t(this.imagePrompt_,"mp_url_instructions");
        f[v](this.imagePrompt_);
        this.imageErrorMsg_=this.doc_[K]("div");
        this.picker_.getConfigParam("newMessages")?Wi(this.imageErrorMsg_,"The file you selected is not a valid image file.  Please select another file."):Wi(this.imageErrorMsg_,"The image URL you have entered above is incorrect or can't be loaded.  Please enter a  correct image URL.");
        t(this.imageErrorMsg_,"mp_url_instructions");
        Wa(this.imageErrorMsg_[H],"none");
        f[v](this.imageErrorMsg_);
        e=this.doc_[K]("tr");
        c[v](e);
        f=this.doc_[K]("td");
        e[v](f);
        Wi(f,this.picker_.getMsg("MSG_URL_CAVEAT"));
        t(f,"mp_url_caveat");
        e=this.doc_[K]("tr");
        c[v](e);
        this.buttonCell_=this.doc_[K]("td");
        e[v](this.buttonCell_);
        t(this.buttonCell_,"mp_buttons");
        e.valign="bottom";
        this.selectButton_=this.doc_[K]("input");
        this.selectButton_.id="mp_select_button";
        t(this.selectButton_,"mp_next");
        Oa(this.selectButton_,
        "button");
        Wa(this.selectButton_[H],"none");
        za(this.selectButton_,this.picker_.getMsg("MSG_SELECT_URL_LABEL"));
        this.buttonCell_[v](this.selectButton_);
        this.eventHandler_.listen(this.selectButton_,"click",this.selectClicked_);
        c=this.doc_[K]("input");
        c.id="mp_cancel_button";
        Oa(c,"button");
        za(c,"Cancel");
        this.buttonCell_[v](c);
        this.eventHandler_.listen(c,"click",this.cancelClicked_);
        return a
    }
    ;
    Q.addProtocol_=function(a){
        if(a&&a.search(/https?:\/\//)!=0)a="http://"+a;
                    return a
                }
                ;
                Q.hasCompleteUrl_=function(){
                    var a=this.addProtocol_(this.urlInput_[D]);
                    return this.picker_.isImage(a)
                }
                ;
                Q.handleInput_=function(){
                    this.delay_[xc]()
                }
                ;
                Q.checkUrl_=function(){
                    var a=this.addProtocol_(this.urlInput_[D]);
                    if(this.imagePreview_.src!=a)if(a){
            this.eventHandler_.listen(this.imagePreview_,"load",this.imageLoaded_);
            this.eventHandler_.listen(this.imagePreview_,"error",this.imageLoadError_);
            try{
                this.imagePreview_.src=a
            }
            catch(b){
                this.doneImageLoaded_();
                this.setPreviewMode_(k);
                this.imagePreview_.src=""
            }
        }
        else{
            this.setPreviewMode_(k);
            this.imagePreview_.src=""
        }
    }
    ;
    Q.setPreviewMode_=function(a){
        var b=this.hasCompleteUrl_();
        Qj(this.imagePrompt_,!a&&!b);
        Qj(this.imageErrorMsg_,!a&&b);
        Qj(this.imagePreview_,a);
        Qj(this.selectButton_,a)
    }
    ;
    Q.doneImageLoaded_=function(){
        this.eventHandler_.unlisten(this.imagePreview_,"load",this.imageLoaded_);
        this.eventHandler_.unlisten(this.imagePreview_,"error",this.imageLoadError_)
    }
    ;
    Q.imageLoaded_=function(){
        this.imagePreview_.removeAttribute("width");
        this.imagePreview_.removeAttribute("height");
        X&&this.setPreviewMode_(i);
        this.adjustPreviewSize_();
        X||this.setPreviewMode_(i);
        this.doneImageLoaded_()
    }
    ;
    Q.imageLoadError_=function(){
        this.setPreviewMode_(k);
        this.doneImageLoaded_()
    }
    ;
    Q.adjustPreviewSize_=function(){
        var a=this.imagePreview_[z],b=this.imagePreview_[P],c=100,e=340;
        if(b>c){
            e=r[ub](a*c/b);
            ta(this.imagePreview_,e);
            Xa(this.imagePreview_,c)
        }
        else if(a>e){
            c=r[ub](b*e/a);
            ta(this.imagePreview_,e);
            Xa(this.imagePreview_,c)
        }
        if(0==a||0==b)p[yb](T(this.adjustPreviewSize_,this),0)
    }
    ;
    Q.selectClicked_=function(){
        var a=this.addProtocol_(this.urlInput_[D]),b=a[Fb]("/");
        b=b[b[x]-1];
        a=new ar(b,"image/*",a,a);
        a.setDimensions(this.imagePreview_[z],this.imagePreview_[P]);
        (b=this.picker_.getBooleanConfigParam("cropEnabled"))&&this.picker_.setCropView();
        this.picker_.setPhoto(a,8);
        b||this.picker_.doneSelect()
    }
    ;
    Q.cancelClicked_=function(){
        this.picker_.cancel();
        this.picker_.hide()
    }
    ;
    Ta(Q,function(){
        this.delay_[cb]();
        za(this.urlInput_,"");
        this.setPreviewMode_(k);
        this.imagePreview_.src=""
    }
    );
    var zr=["photos.www.orkut.com","photos.www.orkut.com.br","photos.www.orkut.co.in","picasaweb.google.com","photos.blogger.com","photos.www.blogger.com","photos.draft.blogger.com"],Ar=["photos.www.orkut.com/lh/addPhotos","photos.www.orkut.com.br/lh/addPhotos","photos.www.orkut.co.in/lh/addPhotos","picasaweb.google.com/lh/addPhotos","photos.draft.blogger.com/lh/addPhotos","photos.blogger.com/lh/addPhotos","photos.www.blogger.com/lh/addPhotos","picasaweb.google.com/data/feed/api/user","mail.google.com/mail/photos",
    "mail.google.com/a","/contacts","/mail/c","/a/c","/c","/local/add/","resources/"];
    var Br=j,Dr=function(a,b,c,e){
        this.win_=a;
        this.callback_=b;
        this.config_=c||{
        }
        ;
        this.imageUrlBase_=Cr.sanitize("imageUrlBase",this.config_.imageUrlBase)||"";
        var f;
        a=pr;
        b={
        }
        ;
        for(f in a)b[f]=a[f];
        this.messages_=f=b;
        f=this.config_.messages||{
        }
        ;
        f=Cr.sanitize("messages",f);
        mf(this.messages_,f);
        this.appSources_=e||{
        }
        ;
        this.appViews_=[];
        Br=this;
        this.callbackMode_="albums";
        this.setupDefaults_();
        this.albumList_=[];
        this.sourceList_=[];
        this.userFeedMap_={
        }
        ;
        this.viewMode_=-1;
        this.queryInProgress_=k;
        this.userId_=
        this.getConfigParam("userId");
        this.selectedPhoto_=this.selectedAlbum_=j;
        this.imageFilterExp_=la(this.getConfigParam("imageFilter"),"i");
        this.theme_=(e=this.getConfigParam("theme"))?"_"+e:"";
        e=this.getBooleanConfigParam("imagePickOnly");
        f=this.getBooleanConfigParam("defaultAlbumOnly");
        this.contents_=this.makeFrame_();
        if(!e){
            this.uploadView_=new xr(this,this.getConfigParam("fileUploadUrl"));
            this.cropView_=new ir(this);
            this.suggestView_=new tr(this);
            this.evergreenView_=new jr(this);
            this.noPhotoView_=
            new mr(this,this.getConfigParam("dpUrl"));
            this.urlView_=new yr(this)
        }
        if(!e||e&&!f)this.albumListView_=new hr(this);
        this.grid_=new lr(this);
        this.currentSource_=j;
        this.currentSourceIndex_=0;
        this.loadSources_();
        this.sourcePanel_=new rr(this);
        this.layoutPickerDialog_();
        this.win_[Ab][dc][v](this.container_);
        (e=this.getConfigParam("eUrl"))&&this.evergreenView_.setPicture(e);
        p==top&&this.centerPicker_()
    }
    ;
    U(Dr,uh);
    Dr[y].useDefaultAlbumFeed_=k;
    var Er={
        USER_ID:"userId",FILE_UPLOAD_URL:"fileUploadUrl",LEFT:"left",TOP:"top",CROP_ENABLED:"cropEnabled",URL_ENABLED:"urlEnabled",PICASAWEB_ENABLED:"picasaWebEnabled",CLEAR_LIST_AFTER_UPLOAD:"clearListAfterUpload",AUTO_LOAD:"autoLoad",SUPPRESS_HIDE:"suppressHide",POST_FILENAME:"postFilename",IMAGE_URL_BASE:"imageUrlBase",PICASA_WEB_DOMAIN:"picasaWebDomain",PICASA_ALBUMS_URL:"picasaAlbumsUrl",PICASA_IMAGE_MAX:"imgmax",PICASA_THUMBNAIL_SIZE:"thumbsize",EXTRA_UPLOAD_PARAMS:"extraUploadParams",EXTRA_PICASAWEB_PARAMS:"extraPicasaWebParams",
        DEFAULT_UPLOAD_ALBUM:"defaultUploadAlbum",UPLOAD_ALBUM_SELECT:"uploadAlbumSelect",SHOW_UPLOAD_TITLE:"showUploadTitle",PHOTO_DISPLAY_NAME:"photoDisplayName",EXTRA_ALBUM:"extraAlbum",DEFAULT_ALBUM_FEED_URL:"defaultAlbumFeedUrl",DEFAULT_ALBUM_ONLY:"defaultAlbumOnly",IMAGE_PICK_ONLY:"imagePickOnly",ALBUM_PANE_MESSAGE:"albumPaneMsg",ALBUM_PANE_TITLE:"albumPaneTitle",CROP_PANE_TITLE:"cropPaneTitle",EVERGREEN_URL:"eUrl",DEFAULT_PHOTO_URL:"dpUrl",ALBUMLIST_USERNAME_SHOW:"usernameShow",ALBUMLIST_SUBTITLE_SHOW:"albumListSubShow",
        PROFILE_MODE:"profileMode",AUTH_TOKEN:"tok",EXTRA_FEED_PARAMS:"extraFeedParams",IMAGE_FILTER:"imageFilter",NEW_MESSAGES:"newMessages",THEME_NAME:"theme",DEFAULT_PICASA_SOURCE:"defaultPicasaSource",DEFAULT_ALBUM_SUBTITLE:"defaultAlbumSubtitle",DEFAULT_ALBUM_SUBTITLE_NO_USER:"defaultAlbumSubtitleNoUser",MESSAGE_OVERRIDES:"messages",RECTANGULAR_CROP:"rectangularCrop",CROP_ASPECT:"cropaspect",TRANSPORT:"transport"
    }
    ,Fr=function(){
        var a=function(s){
            return s==1
        }
        ,b=function(s){
            return fa(s)
        }
        ,c=this.sanitizeUrl_,
        e=T(this.sanitizeDomain_,this),f=T(this.sanitizeWhiteListedUrl_,this),g=function(s){
            return s
        }
        ,h=function(s){
            s=se(s);
            s=s[B](/&amp;
            laquo;
            /g,"&laquo;
");
            return s=s[B](/&amp;
            raquo;
            /g,"&raquo;
")
        }
        ,n=function(s){
            var A;
            s=s;
            var G=h,R={
            }
            ;
            for(A in s)R[A]=G[J](void 0,s[A],A,s);
            return A=R
        }
        ,o={
        }
        ;
        o.userId=g;
        o.fileUploadUrl=f;
        Da(o,b);
        o.top=b;
        o.cropEnabled=a;
        o.urlEnabled=a;
        o.picasaWebEnabled=a;
        o.clearListAfterUpload=a;
        o.autoLoad=a;
        o.suppressHide=a;
        o.postFilename=h;
        o.imageUrlBase=h;
        o.picasaWebDomain=e;
        o.picasaAlbumsUrl=
        f;
        o.imgmax=b;
        o.thumbsize=b;
        o.extraUploadParams=h;
        o.defaultUploadAlbum=h;
        o.uploadAlbumSelect=a;
        o.showUploadTitle=a;
        o.photoDisplayName=h;
        o.extraAlbum=h;
        o.defaultAlbumFeedUrl=f;
        o.defaultAlbumOnly=a;
        o.imagePickOnly=a;
        o.albumPaneMsg=h;
        o.albumPaneTitle=h;
        o.cropPaneTitle=h;
        o.eUrl=f;
        o.dpUrl=c;
        o.usernameShow=a;
        o.profileMode=a;
        o.tok=g;
        o.extraFeedParams=h;
        o.imageFilter=g;
        o.newMessages=a;
        o.theme=h;
        o.defaultPicasaSource=h;
        o.defaultAlbumSubtitle=h;
        o.defaultAlbumSubtitleNoUser=h;
        o.messages=n;
        o.rectangularCrop=a;
        o.cropaspect=b;
        o.transport=h;
        this.fns_=o
    }
    ;
    Fr[y].sanitize=function(a,b){
        var c=this.fns_[a];
        return c?c(b):b
    }
    ;
    Fr[y].sanitizeUrl_=function(a){
        var b=ai(a);
        b=b.getScheme();
        return!b||b=="http"||b=="https"?a:j
    }
    ;
    Fr[y].sanitizeDomain_=function(a){
        var b=ai(a);
        b=b.getDomain()[zd]();
        for(var c=0;
        c<zr[x];
        c++)if(b==zr[c])return a;
        return j
    }
    ;
    Fr[y].sanitizeWhiteListedUrl_=function(a){
        if(ve(a,'"')||ve(a,"'")||ve(a,">")||ve(a,"<"))return j;
        var b=ai(a),c=b.getScheme();
        if(!c||c=="http"||c=="https"){
            c=Zh(b.getPath());
            b=m(b.getDomain()+c)[zd]();
            for(c=0;
            c<Ar[x];
            c++)if(b[E](Ar[c])==0)return a
        }
        return j
    }
    ;
    var Cr=new Fr;
    Q=Dr[y];
    Q.getTheme=function(){
        return this.theme_
    }
    ;
    Q.addSubview_=function(a){
        a=a.getContainer();
        Qj(a,k);
        this.contentArea_[v](a)
    }
    ;
    Q.centerPicker_=function(){
        var a=Mj(this.container_);
        a.width+=16;
        a.height+=16;
        var b=Mj(Ej()),c=b[z]>a[z]?r[ub](b[z]-a[z])/2:0;
        a=b[P]>a[P]?r[ub](b[P]-a[P])/2:0;
        Kj(this.container_,c,a)
    }
    ;
    Q.layoutPickerDialog_=function(){
        var a=this.getBooleanConfigParam("imagePickOnly"),b=this.getBooleanConfigParam("defaultAlbumOnly"),c=this.win_[Ab][K]("table"),e=this.win_[Ab][K]("tbody"),f=this.win_[Ab][K]("tr");
        this.borderContainer_=this.win_[Ab][K]("td");
        c[v](e);
        e[v](f);
        f[v](this.borderContainer_);
        t(c,"mp_framingTable");
        if(!a){
            t(this.borderContainer_,"mp_sourceContainer"+this.theme_);
            xa(this.borderContainer_,"&nbsp;
&nbsp;
");
            this.sourcePanelContainer_=this.win_[Ab][K]("td");
            ta(this.sourcePanelContainer_,
            "148px");
            f[v](this.sourcePanelContainer_);
            t(this.sourcePanelContainer_,"mp_sourceContainer"+this.theme_);
            this.sourcePanelContainer_[v](this.sourcePanel_.getContainer())
        }
        this.contentArea_=this.win_[Ab][K]("td");
        f[v](this.contentArea_);
        a||this.addSubview_(this.uploadView_);
        b||this.addSubview_(this.albumListView_);
        this.addSubview_(this.grid_);
        if(!a){
            this.addSubview_(this.cropView_);
            this.addSubview_(this.suggestView_);
            this.addSubview_(this.evergreenView_);
            this.addSubview_(this.noPhotoView_);
            this.addSubview_(this.urlView_)
        }
        for(a=
        0;
        a<this.appViews_[x];
        a++){
            b=this.appViews_[a];
            this.addSubview_(b)
        }
        this.contents_[v](c)
    }
    ;
    Q.setupDefaults_=function(){
        var a={
        }
        ;
        a.fileUploadUrl="../update/uploadImage";
        Da(a,"0");
        a.top="0";
        a.cropEnabled=1;
        a.urlEnabled=1;
        a.picasaWebEnabled=1;
        a.clearListAfterUpload=0;
        a.autoLoad=1;
        a.suppressHide=0;
        a.showUploadTitle=1;
        a.newMessages=0;
        a.albumPaneTitle="";
        a.cropPaneTitle="";
        a.postFilename="imagefile";
        a.imageUrlBase="../static/images/";
        a.picasaWebDomain="http://picasaweb.google.com";
        a.picasaAlbumsUrl="http://picasaweb.google.com/data/feed/api/user/_NO_USER_SPECIFIED";
        a.imgmax="1600";
        a.thumbsize=
        "144";
        a.extraUploadParams="";
        a.uploadAlbumSelect=0;
        a.usernameShow=1;
        a.albumListSubShow=1;
        a.imageFilter=".jpg$|.jpeg$|.gif$|.png$";
        a.defaultPicasaSource="Picasa Web Albums";
        a.rectangularCrop=0;
        a.cropaspect=-1;
        a.defaultAlbumSubtitle="Picasa Web Albums for ";
        a.defaultAlbumSubtitleNoUser="Picasa Web Albums";
        this.defaultConfig_=a
    }
    ;
    Q.getConfigParam=function(a){
        var b=this.config_[a];
        if(b!=j)return b;
        return this.defaultConfig_[a]||""
    }
    ;
    Q.getBooleanConfigParam=function(a){
        a=this.getConfigParam(a);
        return fa(a)!=0
    }
    ;
    Q.isProfileMode=function(){
        return this.getBooleanConfigParam("profileMode")
    }
    ;
    Q.getWindow=function(){
        return this.win_
    }
    ;
    Q.getDocument=function(){
        return this.win_[Ab]
    }
    ;
    Q.getDialog=function(){
        return this.container_
    }
    ;
    Q.getUserId=function(){
        return this.userId_
    }
    ;
    Q.getImageUrl=function(a){
        return this.imageUrlBase_+a
    }
    ;
    Q.getSpinImageUrl=function(){
        return this.getImageUrl("Spin.gif")
    }
    ;
    Q.getPlaceholderImageUrl=function(){
        return this.getImageUrl("Transparent.gif")
    }
    ;
    Q.setUserId=function(a){
        this.userId_=a;
        this.currentSource_&&this.currentSource_.setUserId(a)
    }
    ;
    Q.show=function(){
        var a=this.getBooleanConfigParam("imagePickOnly"),b=this.getBooleanConfigParam("defaultAlbumOnly");
        if(a)b?this.setGridView(this.currentSource_):this.setAlbumListView();
        else this.setUploadView();
        this.sourcePanel_[ed]();
        Qj(this.container_,i)
    }
    ;
    Q.hide=function(){
        this.getBooleanConfigParam("suppressHide")||Qj(this.container_,k)
    }
    ;
    Ta(Q,function(){
        this.uploadView_&&this.uploadView_[ed]();
        this.urlView_&&this.urlView_[ed]();
        this.uploadView_&&this.setUploadView();
        delete this.userFeedMap_;
        this.userFeedMap_={
        }
        ;
        this.userFeed_&&this.userFeed_[ed]();
        this.dm_&&this.dm_[ed]();
        if(this.defaultAlbumFeed_){
            delete this.defaultAlbumFeed_;
            this.defaultAlbumFeed_=this.getDefaultAlbumFeed();
            this.picasaSource_.setPhotosFeed(this.defaultAlbumFeed_)
        }
        this.sourcePanel_&&this.sourcePanel_[ed]()
    }
    );
    Q.dispose=function(){
        this.sourcePanel_.dispose();
        this.uploadView_.dispose();
        this.grid_.dispose();
        this.albumListView_.dispose();
        this.cropView_.dispose();
        this.suggestView_.dispose();
        this.noPhotoView_.dispose()
    }
    ;
    Q.close=function(a){
        this.hide();
        this.dispose();
        a||this.container_[O][hc](this.container_)
    }
    ;
    Q.getContent=function(){
        return this.content_
    }
    ;
    Q.getSourceList=function(){
        return this.sourceList_
    }
    ;
    Q.getCurrentSource=function(){
        return this.currentSource_
    }
    ;
    Q.getPicasaSource=function(){
        return this.picasaSource_
    }
    ;
    Q.setCurrentSource=function(a){
        this.currentSource_=a
    }
    ;
    Q.getUnescapedPhotoDisplayName=function(){
        return this.getConfigParam("photoDisplayName")
    }
    ;
    Q.isQueryInProgress=function(){
        return this.queryInProgress_
    }
    ;
    Q.setQueryInProgress=function(a){
        this.queryInProgress_=a
    }
    ;
    Q.setAlbum=function(a){
        this.selectedAlbum_=j;
        if(this.currentSource_==this.picasaSource_){
            this.picasaSource_.setPhotosFeed(this.getFeedForAlbum(a));
            this.selectedAlbum_=a
        }
        this.grid_.setSource(this.currentSource_);
        this.grid_.setAlbum(a)
    }
    ;
    Q.setPhoto=function(a,b){
        (this.selectedPhoto_=a)&&this.getBooleanConfigParam("cropEnabled")&&this.cropView_.setPhoto(a,b)
    }
    ;
    Q.addSource_=function(a){
        this.sourceList_[w](a)
    }
    ;
    function _showCropView(a,b){
        a.showCropView_(b)
    }
    Q.showCropView_=function(a){
        this.setPhoto(a,0);
        this.cropView_.disableButtons(k);
        this.setCropView();
        this.sourcePanel_[ed]();
        Wa(this.container_[H],"block")
    }
    ;
    Q.showSuggestView=function(a){
        a&&this.suggestView_.setImageUrl(a);
        this.setSuggestView()
    }
    ;
    Q.appendExtraUrlParams=function(a){
        var b=this.getConfigParam("extraPicasaWebParams");
        if(b)a+="&"+b[B](";
","&");
        return a
    }
    ;
    Q.sendResult_=function(a){
        var b=this.config_.tok;
        if(b)a.tok=b;
        this[F](a);
        this.callback_&&this.callback_(a)
    }
    ;
    Q.done_=function(a){
        if(this.selectedPhoto_){
            var b="";
            if(this.selectedPhoto_.getAlbumId)b=this.selectedPhoto_.getAlbumId();
            a={
type:"PHOTO_PICKED",imageUrl:this.selectedPhoto_.getContentUrl(),thumbnailUrl:this.selectedPhoto_.getThumbnailUrl(),cropString:a,photoId:this.selectedPhoto_.getId(),albumId:b
            }
            ;
            this.sendResult_(a)
        }
    }
    ;
    Q.uploadComplete=function(){
        this.getBooleanConfigParam("clearListAfterUpload")&&this.grid_.clearPhotoList()
    }
    ;
    Q.doneSelect=function(){
        this.done_("0,0,1,1")
    }
    ;
    Q.doneCrop=function(a){
        this.cropView_.disableButtons(i);
        this.done_(a)
    }
    ;
    Q.doneSuggest=function(a){
        this.suggestView_.disableButtons(i);
        if(this.selectedPhoto_){
            a={
type:"SUGGEST_DONE",suggestMessage:a
            }
            ;
            this.sendResult_(a)
        }
    }
    ;
    Q.doneEvergreen=function(){
        this.evergreenView_.disableButtons(i);
        if(this.selectedPhoto_){
            var a={
type:"PHOTO_PICKED",evergreen:i
            }
            ;
            this.sendResult_(a)
        }
    }
    ;
    Q.doneNoPhoto=function(){
        this.noPhotoView_.disableButtons(i);
        var a={
type:"PHOTO_PICKED",noPhoto:i
        }
        ;
        this.sendResult_(a)
    }
    ;
    Q.cancel=function(){
        this.sendResult_({
type:"cancel"
        }
        )
    }
    ;
    Q.setView=function(a){
        if(this.currentView_!=a){
            this.currentView_!=j&&Qj(this.currentView_.getContainer(),k);
            Qj(a.getContainer(),i);
            if(a==this.cropView_||a==this.suggestView_){
                this.sourcePanelContainer_&&Qj(this.sourcePanelContainer_,k);
                this.sourcePanel_.hide()
            }
            else{
                this.sourcePanelContainer_&&Qj(this.sourcePanelContainer_,i);
                this.sourcePanel_.show()
            }
            Qj(this.borderContainer_,a!=this.cropView_);
            this.currentView_=a
        }
        a.activate()
    }
    ;
    Q.isImage=function(a){
        return!!a[nc](this.imageFilterExp_)
    }
    ;
    Q.setCropView=function(a){
        a&&this.cropView_.setSource(a);
        this.setView(this.cropView_)
    }
    ;
    Q.setUploadView=function(){
        this.setView(this.uploadView_)
    }
    ;
    Q.setAlbumListView=function(){
        this.setView(this.albumListView_)
    }
    ;
    Q.setGridView=function(a){
        this.grid_.setSource(a);
        this.setView(this.grid_)
    }
    ;
    Q.setSuggestView=function(){
        this.setView(this.suggestView_)
    }
    ;
    Q.setUrlView=function(){
        this.setView(this.urlView_)
    }
    ;
    Q.getSelectedPanel=function(){
        return this.currentView_
    }
    ;
    Q.makeFrame_=function(){
        var a=this.getBooleanConfigParam("imagePickOnly");
        this.container_=this.win_[Ab][K]("div");
        t(this.container_,"mediaPicker"+(a?" image-pick-only":""));
        this.container_[H].top=this.getConfigParam("top")+"px";
        Da(this.container_[H],this.getConfigParam("left")+"px");
        a=this.win_[Ab][K]("div");
        t(a,"mp_border"+this.theme_);
        this.container_[v](a);
        var b=this.win_[Ab][K]("div");
        t(b,"mp_contents");
        a[v](b);
        return b
    }
    ;
    Q.initFeedSource_=function(a,b){
        var c=this.getConfigParam("imgmax"),e=this.getConfigParam("thumbsize");
        c&&a.setImageMax(fa(c));
        c=[b||160];
        e&&c[w](fa(e));
        a.setThumbnailSizes(c)
    }
    ;
    Q.getFeedForAlbum=function(a){
        a=a.getFeed();
        a.setEntityWatcher(or);
        var b=a.getSource();
        this.initFeedSource_(b);
        return a
    }
    ;
    Q.getDefaultAlbumFeed=function(){
        var a=j;
        if(!this.defaultAlbumFeed_){
            var b=this.getConfigParam("defaultAlbumFeedUrl");
            if(b){
                b=new fq(b);
                this.initFeedSource_(b);
                this.defaultAlbumFeed_=new Cq(this.dm_,b);
                this.defaultAlbumFeed_.setEntityWatcher(or);
                this.useDefaultAlbumFeed_=i
            }
            else{
                delete this.defaultAlbumFeed_;
                this.useDefaultAlbumFeed_=k
            }
        }
        if(this.useDefaultAlbumFeed_)a=this.defaultAlbumFeed_;
        return a
    }
    ;
    Q.getUserFeed=function(a){
        var b=this.userFeedMap_[a];
        if(!b){
            b=this.getConfigParam("picasaAlbumsUrl");
            b=new Lq(b,a);
            this.initFeedSource_(b,32);
            b=new Cq(this.dm_,b);
            var c=this.config_.picasaRewrites;
            c&&b.setEntityWatcher(function(e){
                e.rewriteLinks(c)
            }
            );
            this.userFeedMap_[a]=b
        }
        return b
    }
    ;
    Q.loadSources_=function(){
        var a=this.getBooleanConfigParam("imagePickOnly");
        if(!a){
            this.addSource_(new sr(this.getMsg("MSG_PANEL_CHOOSE")));
            var b=new qr("My Computer",j,j,j,0,this.uploadView_);
            this.addSource_(b)
        }
        a=this.getConfigParam("defaultAlbumFeedUrl");
        var c=this.getConfigParam("defaultAlbumOnly"),e=this.getBooleanConfigParam("picasaWebEnabled");
        if(e){
            e=this.getConfigParam("transport")=="xhr"?new Pq:new Xq;
            this.dm_=new Rq(e);
            this.userFeed_=this.getUserFeed(this.userId_);
            e=this.getConfigParam("defaultPicasaSource");
            if(c){
                this.picasaSource_=new dr(e,this.userId_,this,2,this.grid_);
                this.initFeedSource_(this.userFeed_.getSource(),160);
                a?this.picasaSource_.setPhotosFeed(this.getDefaultAlbumFeed()):this.grid_.displayErrorMessage(this.grid_.gridViewMsgs_.MSG_NO_IMAGES_FOUND)
            }
            else{
                this.getBooleanConfigParam("uploadAlbumSelect")&&this.userFeed_.loadAll(T(this.loadAlbumJson_,this));
                this.picasaSource_=new dr(e,this.userId_,this,1,this.albumListView_)
            }
            this.picasaSource_.setAlbumsFeed(this.userFeed_);
            this.addSource_(this.picasaSource_)
        }
        if(this.getBooleanConfigParam("urlEnabled")){
            a=
            new qr("Web Address (URL)",j,j,j,8,this.urlView_);
            this.addSource_(a)
        }
        if(this.config_.eUrl||this.config_.dpUrl){
            this.addSource_(new sr("Or Select:"));
            if(this.config_.eUrl)this.isProfileMode()||this.addSource_(new qr("Their Picture",j,j,j,6,this.evergreenView_));
            this.config_.dpUrl&&this.addSource_(new qr("No Picture",j,j,j,7,this.noPhotoView_))
        }
        for(a=0;
        a<this.appSources_[x];
        a++){
            c=this.appSources_[a];
            this.addSource_(c);
            c=c[gc];
            if(c!=j){
                c.setPicker(this);
                this.appViews_[w](c)
            }
        }
        this.currentSource_=b
    }
    ;
    Q.isDefaultAlbum=function(a){
        if(!a)return k;
        var b=this.getConfigParam("defaultAlbumFeedUrl");
        if(b&&a){
            a=(new Sh(a.feedLink_)).getPath();
            b=(new Sh(b)).getPath();
            return a==b
        }
        return k
    }
    ;
    Q.loadAlbumJson_=function(a){
        this.albumItems_=a.getAllItems();
        a=this.getBooleanConfigParam("imagePickOnly");
        if(this.picasaSource_&&(this.albumItems_[x]==1||a)){
            var b=this.albumItems_[0];
            if(this.isDefaultAlbum(b)){
                this.picasaSource_.selectMode=2;
                this.defaultAlbumFeed_=this.getFeedForAlbum(b);
                this.picasaSource_.setPhotosFeed(this.defaultAlbumFeed_);
                this.grid_.setDefaultAlbumOnly(i);
                this.grid_.setSource(this.picasaSource_);
                this.picasaSource_.view=this.grid_;
                if(this.currentView_==this.albumListView_||
                        a)this.setGridView(this.picasaSource_)
            }
        }
        a=new Ig("albumsready",this);
        this[F](a)
    }
    ;
    Q.getAlbums=function(a){
        this.albumItems_?a(this.albumItems_):this[Lc]("albumsready",function(b){
            a(b[I].albumItems_)
        }
        )
    }
    ;
    Q.selectAlbum=function(a){
        this.albumListView_.selectItem(a)
    }
    ;
    Q.setContent=function(a){
        this.content_=a
    }
    ;
    var Gr=function(a,b,c){
        b=new Sh(q[Rb][Rc]);
        b=b.getQueryData();
        var e=b.get("done"),f=a||"..";
        a={
        }
        ;
        a.fileUploadUrl=f+"/update/uploadImage";
        a.imageUrlBase=f+"/static/images/";
        a.dpUrl=f+"/static/images/NoPicture.gif";
        a.photoDisplayName=b.get("dn");
        a.top=0;
        Da(a,0);
        a.tok=c;
        for(var g in Er){
            c=Er[g];
            if(f=b.get(c))a[c]=Cr.sanitize(c,f)
        }
        g=new Dr(p,function(h){
            if(e){
                var n=p.opener||p[ic];
                n[yb](T(n[e],j,h),10)
            }
        }
        ,a);
        g.show();
        return g
    }
    ,Hr=function(a,b,c,e){
        a=new Dr(a,b,c,e);
        a.show();
        return a
    }
    ;
    Hd("createPhotoPicker",Hr,void 0);
    var Ir=function(a,b,c,e){
        return new Dr(a,b,c,e)
    }
    ;
    Hd("newPhotoPicker",Ir,void 0);
    var Jr=function(){
        var a=Gr[$c](j,arguments);
        Hd("picker",a,void 0)
    }
    ;
    Hd("initPhotoPicker",Jr,void 0);
    var Kr=function(a){
        var b=Id("picker");
        if(a[Zc]=="SHOW_SUGGEST")b.showSuggestView(a.imageUrl);
        else if(a[Zc]=="CLOSE")b[ac](k);
        else a[Zc]=="CLOSE_NO_REMOVE"&&b[ac](i)
    }
    ;
    Hd("UI_receive",Kr,void 0);
    Dr[y].selectAlbum=Dr[y].selectAlbum;
    function _json_callback(a){
        var b=Br;
        b.setQueryInProgress(k);
        b.jsonLoaded_=i;
        if(b.callbackMode_==0){
            var c=b.currentSource_;
            b.content_=c.extractAlbums(a);
            c[gc]!=j?c[gc].sourcesChanged():b.albumListView_.sourcesChanged()
        }
        else if(b.callbackMode_==2){
            b.content_=b.currentSource_.extractAlbums(a);
            b.uploadView_.albumsChanged(b.content_)
        }
        else{
            a=b.currentSource_.extractPhotos(a);
            if(b.selectedAlbum_)for(c=0;
            c<a[x];
            c++){
                var e=a[c];
                b.selectedAlbum_.addItem(e)
            }
            else b.grid_.setPhotoList(a);
            b.grid_.sourcesChanged()
        }
    }
    function Lr(){
        this[sc]=="loaded"&&!this.picker_.jsonLoaded_&&Mr(this.picker_)
    }
    function Nr(){
        Mr(this.picker_)
    }
    function Mr(a){
        a.setQueryInProgress(k);
        var b=a.getSelectedPanel();
        b.displayErrorMessage(a.getMsg("MSG_SCRIPT_LOAD_ERROR"))
    }
    Dr[y].getMsg=function(a){
        return this.messages_[a]||""
    }
    ;
    Dr[y].fetchJSONData=function(a,b){
        this.callbackMode_=b;
        this.setQueryInProgress(i);
        var c=this.win_[Ab][xd]("head")[Tb](0),e=this.win_[Ab][Ib]("mp_json_script");
        e&&c[hc](e);
        if(e=this.getConfigParam("extraFeedParams"))a+="&"+e;
        this.jsonLoaded_=k;
        e=this.win_[Ab][K]("script");
        Oa(e,"text/javascript");
        e.id="mp_json_script";
        e.picker_=this;
        oa(e,Lr);
        e.onerror=Nr;
        e[Pc]("src",a+"&callback=_json_callback");
        c[v](e)
    }
    ;
    var Or=function(a){
        this.importUri_=a;
        this.contactsDs_=Lm();
        a=Sk();
        a[M]("IMPORT_SHOW",T(this.showDetails_,this));
        a[M]("IMPORT_UPLOAD_FILE",T(this.handleImport,this))
    }
    ;
    Or[y].handleImport=function(){
        var a=new Pp;
        Y(a,"complete",T(this.importFinished_,this,a));
        var b=Z("import-form"),c=Z("import-file");
        if(c[D]=="")ja("Please choose a file to upload.");
        else{
            if(b.addToGroup[wb]==i&&b.addToGroupId[D]=="^New"){
                c=ap(this.contactsDs_,j);
                if(!c)return;
                za(b.addToGroupName,c)
            }
            a.sendFromForm(b,this.importUri_);
            Wa(Z("ImportBase")[H],"none");
            Wa(Z("ImportProgress")[H],"block")
        }
    }
    ;
    Or[y].importFinished_=function(a){
        var b;
        if(a.isSuccess())try{
            b=wh(a.getResponseText())
        }
        catch(c){
            b={
status:"UNKNOWN_ERROR"
            }
        }
        else b={
status:"UNKNOWN_ERROR"
        }
        ;
        a=new ei(b,"$ImportResults");
        V().addDataSource(a);
        S[yb](function(){
            Lm()[Eb](2);
            var e=new Ig("RELOAD_CONTACTS");
            Uk().doEvent(e)
        }
        ,100);
        Wa(Z("ImportBase")[H],"block");
        Wa(Z("ImportProgress")[H],"none");
        $[u]("$ContactManager/Panel","IMPORT_RESULTS")
    }
    ;
    Or[y].showDetails_=function(a){
        a=Z(a.id);
        xj(a,"display","block")
    }
    ;
    var Pr=function(a,b,c,e,f){
        this.dataUtil_=f||$;
        c=c||{
        }
        ;
        if(c.FIXED_HEIGHT==j)c.FIXED_HEIGHT=i;
        if(c.MANUAL_ROWSET==j)c.MANUAL_ROWSET=i;
        Ip[J](this,a,b,c);
        this.matchDomain_=this.getConfig("MATCH_DOMAIN",k);
        this.considerNonPrimaryEmails_=e
    }
    ;
    U(Pr,Ip);
    Q=Pr[y];
    Q.groupId_="";
    Q.token_="";
    Q.hideNoEmail_=k;
    Q.setGroup=function(a){
        if(this.groupId_!=a){
            this.groupId_=a;
            this.recalculateData()
        }
    }
    ;
    Q.recalculateData=function(){
        var a=this.rowsExpr_.getNodes();
        if(this.matcher_){
            for(var b=[],c=[],e=[],f=[],g=0;
            g<a.getCount();
            g++){
                var h=a.getByIndex(g);
                if(this.shouldRenderRow(h))if(h.isInGroup("^Mine"))b[w](h);
                else if(h.isDomainContact())c[w](h);
                else h.isDomainGroup()?e[w](h):f[w](h)
            }
            b[Mc](Ko);
            f[Mc](Ko);
            this.dataUtil_.getNode("$ContactManager")&&this.setSearchCounts_(b,f,c,e);
            this.setSectionHeaders(this.getSectionHeaders_(b,f,c,e));
            this.setRows(this.concatenateRows_(b,f,c,e))
        }
        else{
            b=[];
            for(g=0;
            g<
            a.getCount();
            g++){
                h=a.getByIndex(g);
                this.shouldRenderRow(h)&&b[w](h)
            }
            this.setSectionHeaders(j);
            this.setRows(b)
        }
    }
    ;
    Q.concatenateRows_=function(a,b,c,e){
        var f=[];
        Ve(f,a);
        if(a=this.dataUtil_[C]("$ContactManager/ExpNewSectionHeaderOrder")){
            Ve(f,b);
            Ve(f,c);
            Ve(f,e)
        }
        else{
            Ve(f,c);
            Ve(f,e);
            Ve(f,b)
        }
        return f
    }
    ;
    Q.setSearchCounts_=function(a,b,c,e){
        this.dataUtil_[u]("$ContactManager/MineSearchCount",a[x]);
        this.dataUtil_[u]("$ContactManager/DomainSearchCount",c[x]);
        this.dataUtil_[u]("$ContactManager/DomainGroupSearchCount",e[x]);
        this.dataUtil_[u]("$ContactManager/CollectSearchCount",b[x])
    }
    ;
    Q.getSectionHeaders_=function(a,b,c,e){
        var f=this.dataUtil_[C]("$ContactManager/ExpNewSectionHeaderOrder"),g=0,h=[];
        if(a[x]>0){
            var n="My Contacts ("+(a[x]+")");
            h[w](new Lp(n,g));
            g+=a[x]
        }
        if(!f){
            if(c[x]>0){
                a=this.dataUtil_[C]("$UserData/AspDomainTitle");
                a=a+(" Contacts ("+(c[x]+")"));
                h[w](new Lp(a,g));
                g+=c[x]
            }
            if(e[x]>0){
                a=this.dataUtil_[C]("$UserData/AspDomainTitle");
                a=a+(" Groups ("+(e[x]+")"));
                h[w](new Lp(a,g));
                g+=e[x]
            }
        }
        if(b[x]>0){
            a="Other Contacts ("+(b[x]+")");
            h[w](new Lp(a,g));
            g+=b[x]
        }
        if(f){
            if(c[x]>
                    0){
                a=this.dataUtil_[C]("$UserData/AspDomainTitle");
                b=a+(" Directory ("+(c[x]+")"));
                h[w](new Lp(b,g));
                g+=c[x]
            }
            if(e[x]>0){
                a=this.dataUtil_[C]("$UserData/AspDomainTitle");
                c=a+(" Groups ("+(e[x]+")"));
                h[w](new Lp(c,g))
            }
        }
        return h
    }
    ;
    Q.isSelected=function(a){
        if(!this.selectedGroupId_)return k;
        return this.selectedGroupId_=="^All"?i:this.selectedGroupId_=="^Collect"?!this.dataUtil_[C]("Groups/^Mine/id",a):!!this.dataUtil_[C]("Groups/"+this.selectedGroupId_+"/id",a)
    }
    ;
    Q.setSelectedGroup=function(a){
        if(this.selectedGroupId_!=a){
            this.selectedGroupId_=a;
            this.render()
        }
    }
    ;
    Q.setToken=function(a){
        if(this.token_!=a){
            this.token_=a;
            if(a!=""){
                this.matcher_=new gp(a,this.matchDomain_,this.considerNonPrimaryEmails_);
                this.domainContactMatcher_=new hp(a)
            }
            else this.domainContactMatcher_=this.matcher_=j;
            this.recalculateData()
        }
    }
    ;
    Q.getToken=function(){
        return this.token_
    }
    ;
    Q.getVisibleCount=function(){
        return this.getVisibleRows()[x]
    }
    ;
    Q.getVisibleRows=function(){
        if(this.manualRowSet_)return this.rows_;
        else{
            for(var a=[],b=0;
            b<this.rows_[x];
            b++)this.shouldRenderRow(this.rows_[b])&&a[w](this.rows_[b]);
            return a
        }
    }
    ;
    Q.setHideNoEmail=function(a){
        if(this.hideNoEmail_!=a){
            this.hideNoEmail_=a;
            this.invalidateVisibility_()
        }
    }
    ;
    Q.shouldRenderRow=function(a){
        if(this.hideNoEmail_&&!a.getEmail())return k;
        if(this.matcher_&&this.domainContactMatcher_)return a.getChildNodeValue("DomainContact")?this.domainContactMatcher_[nc](a):this.matcher_[nc](a);
        if(this.groupId_=="^All")return!a.getChildNodeValue("DomainContact");
        else if(this.groupId_=="^Collect"){
            var b=!a.getChildNodeValue("DomainContact")&&!a.isInGroup("^Mine");
            return b&&!a.isNeverSuggest()&&a.getMailsSent()>2
        }
        return a.isInGroup(this.groupId_)
    }
    ;
    Q.renderRow=function(a,b){
        var c=a[db]();
        xa(b,se(c))
    }
    ;
    var Qr=function(a,b,c,e,f){
        Pr[J](this,a,b,c);
        this.actions_=e!=j?e:"ACTION_SELECT_TOGGLE";
        this.staticRoot_=f
    }
    ;
    U(Qr,Pr);
    Q=Qr[y];
    Q.pictureSize_=32;
    Q.imgText_='<div class="picture-div"><img src="{
$Thumb
}
" style="height: {
$PictureSize
}
px;
visibility:hidden;
max-width: {
$PictureSize
}
px;
" onload="fixImage(this)" class="picture"/></div>';
    Q.userText_='<div class="text"><div class="line1">{
$Line1
}
</div><div class="line2">{
$Line2
}
</div></div>';
    Q.actionText_='<div class="action">{
$Action
}
</div>';
    Q.getUserTextHtml_=function(a){
        var b=a.getDisplayName(),c=a.getEmail()||"";
        a=b||c;
        b=b&&b!=c?c:"";
        return b=this.userText_[B](/\{
            \$Line1\
        }
        /g,se(a))[B](/\{
            \$Line2\
        }
        /g,se(b))
    }
    ;
    Q.renderRow=function(a,b){
        var c=a.getChildNodeValue("Photo");
        if(c)c=Wl().getServerBase()+c+"?fb=h&sz="+this.pictureSize_;
        this.isSelected(a)?ui(b,"selected"):vi(b,"selected");
        var e='<div style="float:left;
width: 19px;
height: 20px;
padding-top: 3px;
">';
        if(this.isSelected(a))e+='<img src="'+this.staticRoot_+'images/CheckMark.gif"/>';
        e+="</div>";
        var f="";
        if(c&&a.isInGroup("^Freq")){
            Ud(this);
            f=this.imgText_[B](/\{
                \$Thumb\
            }
            /g,c)[B](/\{
                \$PictureSize\
            }
            /g,m(this.pictureSize_))
        }
        c="";
        var g=j;
        if(this.actions_==
                "SELECT")g="&gt;
";
        else if(this.actions_=="ACTION_SELECT_TOGGLE")g=this.isSelected(a)?"X":"&gt;
";
        if(g)c=this.actionText_[B](/\{
            \$Action\
        }
        /g,g);
        a.getChildNodeValue("DomainContact")&&ui(b,"domainContact");
        xa(b,c+f+e+this.getUserTextHtml_(a))
    }
    ;
    var Rr=function(a,b,c,e){
        Pr[J](this,a,b,c,e)
    }
    ;
    U(Rr,Pr);
    Rr[y].rowText_='<div class="check"><input type="checkbox" id="CCL{
$Index
}
" {
$Checked
}
/></div><div class="text" title="{
$Hover
}
"> {
$Line
}
</div>';
    Rr[y].renderRow=function(a,b){
        this.isSelected(a)?ui(b,"selected"):vi(b,"selected");
        var c=a.getEmail(),e=se(a.getNameForDisplay()),f=this.isSelected(a)?' checked="checked"':"",g=this.getIndexOfRow(b);
        c=se(c||"");
        xa(b,this.rowText_[B](/\{
            \$Line\
        }
        /g,e)[B](/\{
            \$Checked\
        }
        /g,f)[B](/\{
            \$Index\
        }
        /g,g)[B](/\{
            \$Hover\
        }
        /g,c))
    }
    ;
    Rr[y].handleMouseDown_=function(a){
        var b=Di("*","check",a.currentTagret);
        if(b&&b[x]>0){
            var c=Hj(b[0]).x;
            b=c+Mj(b[0])[z];
            if(c-5<=a[Bd]&&a[Bd]<=b+5){
                c=this.getIndexOfRow(a[I]);
                this.handleSelect_(a,c,i);
                return
            }
        }
        Rr.superClass_.handleMouseDown_[J](this,a)
    }
    ;
    var Yr=function(a,b,c,e,f,g,h,n){
        this.contactData_=Lm();
        this.dataManager_=V();
        this.contactData_.enableRichSearchLogging(i);
        this.hasContacts_=k;
        this.baseId_=n||"manager";
        this.staticRoot_=f;
        this.updateRoot_=g;
        this.pageStyle_=h||"NORMAL";
        this.contactDataPath_=a;
        this.groupsDataPath_=b;
        this.fsidExpr_=W(c+"/Value");
        this.contactSelectedExpr_=W("Groups/^Temp");
        this.contactsDs_=W("$Contacts").getNode();
        this.curGroupId_=j;
        Sr||(Sr=new Tr);
        this.nav_=a=Sr;
        Y(this.nav_,"Navigation.GO",this.onNavigate_,k,this);
        Y(this.nav_,
        "Navigation.ALLOW",this.onAllowNavigate_,k,this);
        Y(Uk(),"Navigation.GO",this.onNavigate_,k,this);
        Y(Uk(),"Navigation.ALLOW",this.onAllowNavigate_,k,this);
        Y(Uk(),"MAKE_VISIBLE",this.onMakeVisible_,k,this);
        a=Sk();
        this.groupList_=new Ur(Z(this.baseId_+"-group-list"),this.groupsDataPath_,this.contactDataPath_,j,j);
        this.groupList_.invalidate();
        b={
        }
        ;
        b.MATCH_DOMAIN=i;
        b.MANUAL_ROWSET=i;
        b.SELECT_ON_MOUSE_DOWN=i;
        this.contactList_=new Rr(Z(this.baseId_+"-contact-list"),this.contactDataPath_,b,i);
        this.contactList_.setSelectedGroup("^Temp");
        var o=this;
        a[M]("DELETE_GROUP",function(L){
            o.deleteGroup_(L.groupId)
        }
        );
        a[M]("NEW_CONTACT",T(this.newContact_,this));
        a[M]("NEW_GROUP",function(L){
            o.newGroup_(L.groupName)
        }
        );
        a[M]("DELETE_CURRENT_CONTACT",T(this.deleteCurrentContact_,this));
        a[M]("DELETE_SELECTED_CONTACTS",T(this.deleteSelectedContacts_,this));
        a[M]("SAVE_EDIT_GROUP",T(this.saveCurrentGroup_,this));
        a[M]("MOVE_TO_MINE_GROUP",T(this.moveCurrentContactToMineGroup_,this));
        a[M]("IGNORE_SUGGESTIONS",T(this.ignoreSuggestions_,this));
        a[M]("SHOW_HOME_PANEL",
        function(){
            o.selectDefaultGroup_();
            o.contactData_.unselectContacts();
            o.choosePanel_()
        }
        );
        a[M]("SUBMIT_FORM",function(L){
            if(L.form)(L=Z(L.form))&&L.submit()
        }
        );
        a[M]("CANCEL_CONTACT_EDIT",function(){
            o.choosePanel_(k)
        }
        );
        a[M]("INITIATE_EMAIL",T(this.initiateEmail_,this));
        a[M]("SHOW_EMAILS",T(this.showEmails_,this));
        a[M]("INITIATE_CHAT",T(this.initiateChat_,this));
        a[M]("DISABLE_WINDOW",T(this.disableWindow_,this));
        a[M]("ENABLE_WINDOW",T(this.enableWindow_,this));
        a[M]("CONTACT_CHANGED",T(this.notifyContactChanged_,
        this));
        a[M]("GROUP_CHANGED",T(this.notifyGroupChanged_,this));
        a[M]("CONTACT_MERGED",T(this.notifyContactMerged_,this));
        a[M]("MERGE_SELECTED_CONTACTS",this.createMergePreview_[gd](this));
        a[M]("FIND_DUPLICATED_CONTACTS",T(this.handleFindDuplicatesRequest_,this));
        a[M]("MERGE_DUPLICATED_CONTACTS",T(this.handleMergeDuplicatesRequest_,this));
        a[M]("SHOW_MERGED_CONTACT_DETAILS",T(this.toggleMergedContactDetails_,this));
        a[M]("SHOW_MERGED_CONTACT_EXPAND",T(this.setMergedContactDetailsExpanded_,this,i));
        a[M]("SHOW_MERGED_CONTACT_COLLAPSE",
        T(this.setMergedContactDetailsExpanded_,this,k));
        a[M]("SELECT_MERGE_CANDIDATES",T(this.toggleMergeCandidates_,this));
        a[M]("EDIT_INTERLEAVED",this.editInterleavedPersonalContact_[gd](this));
        a[M]("ADD_INTERLEAVED",this.addInterleavedPersonalContact_[gd](this));
        a[M]("UPDATE_CHAT_INFORMATION",function(L){
            S[yb](function(){
                o.sendChatInformationChange_(L.contactId)
            }
            ,0)
        }
        );
        Y(Uk(),"CHAT_INFORMATION",this.onChatInformation_,k,this);
        a[M]("CONTACT_GROUPS_MENU_OPEN",function(L){
            L=L.source;
            o.refreshGroupMenu_(L)
        }
        );
        a[M]("SELECT_ALL_VISIBLE",function(){
            if(o.nav_.canGoTo("view=MULTIPLE_CONTACTS")){
                for(var L=W("$Contacts/*").getNodes(),Qa=0;
                Qa<L.getCount();
                Qa++){
                    var Yd=L.getByIndex(Qa);
                    o.contactList_.shouldRenderRow(Yd)&&o.contactData_.selectContact(Yd,i)
                }
                o.choosePanel_(k)
            }
        }
        );
        a[M]("DESELECT_ALL",function(){
            if(o.nav_.canGoTo("view=VIEW_GROUP")){
                o.contactData_.unselectContacts();
                o.choosePanel_(k)
            }
        }
        );
        var s=T(o.choosePanel_,o);
        a[M]("ADD_CONTACT_TO_GROUP",function(L){
            if(o.contactData_.isGroupGrowable(L.groupId)||L.groupId==
                    "^New"){
                var Qa=L.selectGroup?function(){
                    o.selectGroup_(L.groupId,k,i)
                }
                :s;
                o.contactData_.addContactByIdToGroup(L.contactId,L.groupId,Qa)
            }
        }
        );
        a[M]("REMOVE_CONTACT_FROM_GROUP",function(L){
            if(!o.contactData_.isGroupLocked(L.groupId)||L.groupId=="^Mine"){
                o.contactData_.removeContactFromGroup(L.contactId,L.groupId,s);
                L.groupId==o.curGroupId_&&o.contactData_.unselectContacts()
            }
        }
        );
        a[M]("REMOVE_SELECTED_CONTACTS_FROM_GROUP",function(L){
            o.contactData_.removeSelectedContactsFromGroup(L.groupId,T(o.choosePanel_,
            o));
            o.contactData_.unselectContacts()
        }
        );
        a[M]("VIEW_SUGGESTIONS",T(function(L){
            L.row=W("$Groups/^Collect").getNode();
            this.groupSelected_(L)
        }
        ,this));
        a[M]("NAVIGATE",function(L){
            o.nav_.tryNavigate(L)
        }
        );
        Y(Uk(),"SELECT_CONTACT",function(L){
            L=L.email;
            o.selectSingleSearchResultOnce_=i;
            o.contactList_.setToken(L);
            Lm()[Eb](4,1,L);
            var Qa=Z(o.baseId_+"-set-token");
            Qa=Qa;
            L=L;
            if(L!=""&&L!=Qa.defaultText){
                Qa.defaulted=k;
                za(Qa,L);
                vi(Qa,"input-default");
                Qa[zc]()
            }
        }
        );
        a[M]("SELECT_GROUP",T(function(L){
            L.row=W("$Groups/"+
            L.id).getNode();
            this.groupSelected_(L)
        }
        ,this));
        a[M]("GOOGLE_VOICE",T(this.googleVoiceEvent_,this));
        Y(Uk(),"GOOGLE_VOICE_IN",Vr,k,this);
        this.messageUi_=new Tl(this.baseId_+"-messages");
        if(this.style_=="TWO"){
            a=Z(this.baseId_+"-select-group-menu-pane");
            b=Z(this.baseId_+"-group-col-top");
            e=Z(this.baseId_+"-group-col-bottom");
            if(a&&b){
                Wa(a[H],"block");
                Wa(b[H],"none");
                if(e)Wa(e[H],"none")
            }
        }
        this.viewer_=new Wr(this.contactsDs_,this.groupsDataPath_,this.updateRoot_,c);
        p.viewer=this.viewer_;
        this.contactImporter_=
        new Or(this.updateRoot_+"import");
        Y(this.contactList_,"SELECT",this.contactSelected_,k,this);
        Y(this.contactList_,"MULTI_SELECT",this.contactMultipleSelected_,k,this);
        Y(this.groupList_,"SELECT",this.groupSelected_,k,this);
        Y(this.contactList_,"LIST_CHANGED",this.contactListChanged_,k,this);
        Y(this.contactList_,"LIST_RENDERED",this.contactListRendered_,k,this);
        Y(this.viewer_,"ContactViewer.CONTACT_SAVED",this.contactSaved_,k,this);
        this.contactList_.invalidate();
        this.groupList_.invalidate();
        (this.closeEl_=
        Z("manager-close"))&&Y(this.closeEl_,"click",this.done_,k,this);
        Y(q,"keydown",function(L){
            if(L[Dc]==8&&L[I][dd]!="INPUT"&&L[I][dd]!="TEXTAREA"){
                L[Sb]();
                L[Ob]();
                return k
            }
        }
        ,k);
        this.dataManager_.addListener(T(this.contactsChanged_,this),"$Contacts");
        this.dataManager_.addListener(T(this.loadRequestChange_,this),"$ContactData/Loading");
        this.dataManager_.addListener(T(this.loadRequestChange_,this),"$ContactData/PendingRequest");
        if(Xr)this.navigateToInitialPanel();
        else{
            var A=this.dataManager_,G="$ContactData/Loaded",
            R=function(){
                var L=$[C](G);
                if(L){
                    o.navigateToInitialPanel();
                    A.removeListeners(R,G)
                }
            }
            ;
            this.dataManager_.addListener(R,G)
        }
    }
    ,Xr,Zr,$r,as,bs,cs,ds;
    mf(Yr[y],uh[y]);
    Q=Yr[y];
    Q.initSearchListeners_=function(){
        if(this.contactData_.domainContactsEnabled()){
            var a=new El(this.tokenEl_),b=T(this.performContactSearch_,this),c=Sk();
            c[M]("SEARCH_CONTACTS",b);
            a[Lc]("ENTER",b);
            Y(this.tokenEl_,"keypress",function(e){
                var f=e[Dc];
                f==13&&e[Sb]()
            }
            )
        }
        else lp(this.contactList_,this.tokenEl_,i)
    }
    ;
    Q.performContactSearch_=function(a){
        var b=this.tokenEl_.defaulted?"":this.tokenEl_[D];
        if(this.contactList_.getToken()!=b){
            za(a,b);
            this.contactData_.clearDomainContacts();
            jp(this.contactList_,a);
            kp(a)
        }
        this.buttonSearch_=i
    }
    ;
    Q.handleFindDuplicatesRequest_=function(){
        if(this.nav_.canGoTo({
view:"FIND_DUPLICATES"
                    }
                    )){
            this.nav_.goTo({
view:"FIND_DUPLICATES"
            }
            );
            var a=T(this.duplicateDetectionFinished,this),b=T(this.duplicateDetectionFinished,this);
            a=new Gp(this.contactsDs_,a,b);
            a[pc]()
        }
    }
    ;
    Q.duplicateDetectionFinished=function(){
        $[u]("$ContactManager/Panel","FIND_DUPLICATES_RESULT")
    }
    ;
    Q.handleMergeDuplicatesRequest_=function(){
        $a(Z("MergeDuplicatesProgress")[H],"visible");
        for(var a=W("$DuplicateDetectionResult/Duplicates/*").getNodes(),b=[],c=0;
        c<a.getCount();
        c++)if(Z("MergeCheckBox-["+c+"]")[wb]){
            for(var e=a.getByIndex(c).getChildNode("DuplicatedContacts").getChildNodes(),f=[],g=0;
            g<e.getCount();
            g++){
                var h=e.getByIndex(g).get();
                f[w](h)
            }
            b[w](f[ud]())
        }
        a=T(this.mergeDuplciatesFinished,this);
        c=T(this.mergeDuplciatesFinished,this);
        b=new Hp(this.contactsDs_,b,a,c);
        b[pc]()
    }
    ;
    Q.toggleMergedContactDetails_=function(a){
        a=a.row;
        a=Z("MergedContactDetails-["+a+"]");
        Wa(a[H],a[H][ld]=="none"?"block":"none")
    }
    ;
    Q.setMergedContactDetailsExpanded_=function(a){
        a=a?"block":"none";
        for(var b=W("$DuplicateDetectionResult/Duplicates/*").getNodes().getCount(),c=0;
        c<b;
        c++)Wa(Z("MergedContactDetails-["+c+"]")[H],a)
    }
    ;
    Q.toggleMergeCandidates_=function(){
        for(var a=Z("MergeCheckBoxAll")[wb],b=W("$DuplicateDetectionResult/Duplicates/*").getNodes().getCount(),c=0;
        c<b;
        c++)va(Z("MergeCheckBox-["+c+"]"),a)
    }
    ;
    Q.mergeDuplciatesFinished=function(){
        Wa(Z("MergeDuplicatesProgress")[H],"none");
        Sk()[Oc](new Ig("SHOW_HOME_PANEL"))
    }
    ;
    Q.navigateToInitialPanel=function(){
        var a=$[C]("$ContactManager/InitialContact"),b=$[C]("$ContactManager/Panel");
        if(a)(a=W("$Contacts/"+a).getNode())&&this.contactSelectedImpl_({
row:a,canPrevent:k
        }
        );
        this.choosePanel_(k,b)
    }
    ;
    Q.groupSelected_=function(a){
        a=a.row.getChildNodeValue("id");
        if(a=this.selectGroup_(a))if(a=Z("select-all-check"))va(a,k)
    }
    ;
    Q.selectGroup_=function(a,b,c){
        Uf.info("Starting group select ("+this.dataManager_.getEventCount()+")");
        var e=k;
        b=b!=j?b:i;
        if((this.curGroupId_!=a||this.contactList_.getToken())&&(!b||this.nav_.canGoTo("view=VIEW_GROUP"))){
            this.curGroupId_=a;
            this.contactList_.setGroup(a);
            this.groupList_.selectGroup(a);
            this.clearToken_();
            this.dataManager_.aliasDataSource("$CurrentGroup","$Groups/"+a);
            e=j;
            if(a=="^Collect")e='These are the people you have contacted frequently. Select the contacts you\'d like to move to My Contacts and click the "Move to My Contacts" button. If you don\'t want certain contacts suggested again, select them and click the "Ignore" button.';
            else if(a=="^Freq")e="Contacts you email and chat with the most.";
            else if(a=="^All")e="These are all of your contacts.";
            $[u]("$ContactManager/CurrentGroupDescription",e);
            a=c?a:j;
            this.contactData_.unselectContactsExceptGroup(a);
            this.choosePanel_(k);
            this.checkAddToGroupAutocomplete_();
            e=i;
            if(this.curGroupId_=="^All"||this.curGroupId_=="^Collect")this.contactData_[Eb](3,1E4)
        }
        Uf.info("Ended group select ("+this.dataManager_.getEventCount()+")");
        return e
    }
    ;
    Q.selectDefaultGroup_=function(){
        this.selectGroup_("^Mine",k)
    }
    ;
    Q.checkAddToGroupAutocomplete_=function(){
        var a=Z("AddToGroupAutocomplete");
        if(a)if(Lm().isGroupGrowable(this.curGroupId_)){
            Aa(a,k);
            vi(a[O],"disabled")
        }
        else{
            a.defaulted||a[Mb]();
            Aa(a,i);
            ui(a[O],"disabled")
        }
    }
    ;
    Q.clearToken_=function(){
        this.contactList_.setToken("");
        this.tokenEl_&&wl(this.tokenEl_)
    }
    ;
    Q.newGroup_=function(a){
        if(this.nav_.canGoTo({
view:"VIEW_GROUP"
                    }
                    )){
            var b=a;
            b||(b=ap(this.contactsDs_));
            if(b){
                var c=this;
                a=new bp(this.contactData_,j,"NEW",b,function(){
                    for(var e=W("$Groups/*").getNodes(),f=0;
                    f<e.getCount();
                    f++){
                        var g=e.getByIndex(f);
                        g.getChildNodeValue("Name")==b&&c.selectGroup_(g.getChildNodeValue("id"),k)
                    }
                }
                );
                a[pc]()
            }
        }
    }
    ;
    Q.deleteGroup_=function(a){
        a=a||$[C]("$CurrentGroup/id");
        var b=W(this.groupsDataPath_+"/"+a+"/Name").getValue();
        b="Are you sure you want to delete the group "+(b+"? This action cannot be undone.");
        if(p.confirm(b)){
            var c=this;
            a=new bp(this.contactData_,a,"DELETE",j,function(){
                c.selectGroup_("^Mine",k)
            }
            );
            a[pc]()
        }
    }
    ;
    Q.initiateEmail_=function(a){
        var b=a.groupId;
        a.to=b?this.getEmailsForGroup_(b,i,i)[ud](", "):Ho(a.to,a[N],i);
        a.to&&np(a.to)
    }
    ;
    Q.createMergePreview_=function(){
        this.contactData_.mergeSelectedContactsPreview(T(this.showMergePreview_,this),j)
    }
    ;
    Q.showMergePreview_=function(){
        this.nav_.canGoTo({
view:"EDIT_CONTACT"
        }
        )&&this.nav_.goTo({
view:"EDIT_CONTACT",canPrevent:i
        }
        )
    }
    ;
    Q.editInterleavedPersonalContact_=function(a){
        if(a=a.id)if(this.nav_.canGoTo({
view:"EDIT_CONTACT"
                    }
                    )){
            a=this.contactData_.getContact(a);
            this.interleavePersonalContact_(a);
            this.contactData_.createTempContact(a.getDataPath());
            this.nav_.goTo({
view:"EDIT_CONTACT",canPrevent:i
            }
            )
        }
    }
    ;
    Q.addInterleavedPersonalContact_=function(a){
        var b=a.id;
        if(b)if(this.nav_.canGoTo({
view:"EDIT_CONTACT"
                    }
                    )){
            a=this.contactData_.createTempContact();
            b=this.contactData_.getContact(b);
            a.setChildNode("Name",b.getName());
            b=b.getChildNode("Emails").getChildNodes();
            if(b=b.getByIndex(0)){
                a.setChildNode("Emails",[b.getJsObject()]);
                this.interleavePersonalContact_(a);
                this.nav_.goTo({
view:"EDIT_CONTACT",canPrevent:i
                }
                )
            }
        }
    }
    ;
    Q.showEmails_=function(a){
        var b=a.contactId;
        if(b){
            b=this.contactData_.getContact(b);
            a.to=b.getEmails()[ud](",")
        }
        if(b=a.groupId)a.to=this.getEmailsForGroup_(b)[ud](",");
        Uk().doEvent(a)&&ja("Will show soon")
    }
    ;
    Q.googleVoiceEvent_=function(a){
        Uk().doEvent(a)
    }
    ;
    Q.getEmailsForGroup_=function(a,b){
        for(var c=this.contactData_.get(),e=[],f=0;
        f<c.getCount();
        f++){
            var g=c.getByIndex(f);
            if(this.contactData_.isContactInGroup(g,a))if(b)g.getEmail()&&e[w](g.getAsEmailString(i,i));
            else e=e[Kb](g.getEmails())
        }
        return e
    }
    ;
    Q.initiateChat_=function(a){
        Uk().doEvent(a)&&ja("TODO: Implement chat links.")
    }
    ;
    Q.disableWindow_=function(a){
        Uk().doEvent(a)
    }
    ;
    Q.enableWindow_=function(a){
        Uk().doEvent(a)
    }
    ;
    Q.requestChatInformation_=function(a){
        var b=this.contactData_.getChildNode(a);
        b=b.getEmails()[ud](",");
        var c=new Ig("REQUEST_CHAT_INFORMATION");
        c.contactId=a;
        c.email=b;
        Uk().doEvent(c)
    }
    ;
    Q.chatInformationChange_=function(a){
        Uk().doEvent(a)
    }
    ;
    Q.sendChatInformationChange_=function(a){
        var b=this.contactData_.getChildNode(a),c=b.getEmails()[ud](","),e=new Ig("CHAT_INFORMATION");
        e.contactId=a;
        e.email=c;
        e.rosterState=b.getChildNodeValue("RosterState");
        e.presence=b.getChildNodeValue("Presence");
        this.chatInformationChange_(e)
    }
    ;
    Q.onChatInformation_=function(a){
        var b=a.contactId,c=a.email,e;
        if(b)e=this.contactData_.getChildNode(b);
        else if(c){
            b=this.contactData_.getSelectedContacts().getChildNodes();
            if(b.getCount()==1){
                b=b.getByIndex(0);
                if(b.getEmail()==c)e=this.contactData_.getChildNode(b.getId())
            }
        }
        if(e){
            e.setChildNode("RosterState",a.rosterState);
            e.setChildNode("Presence",a.presence||"NONE")
        }
    }
    ;
    Q.notifyContactChanged_=function(a){
        Uk().doEvent(a)
    }
    ;
    Q.notifyGroupChanged_=function(a){
        Uk().doEvent(a)
    }
    ;
    Q.notifyContactMerged_=function(a){
        Uk().doEvent(a)
    }
    ;
    Q.newContact_=function(){
        if(this.nav_.canGoTo({
view:"EDIT_CONTACT"
                    }
                    )){
            this.contactData_.unselectContacts();
            this.contactData_.createTempContact();
            this.nav_.goTo({
view:"EDIT_CONTACT",canPrevent:i
            }
            )
        }
    }
    ;
    Q.deleteCurrentContact_=function(){
        var a=$[C]("$CurrentContactId");
        this.contactData_.deleteContact(a,T(this.contactsDeleted_,this),T(this.contactsDeleted_,this))
    }
    ;
    Q.deleteSelectedContacts_=function(){
        this.contactData_.deleteSelectedContacts(T(this.contactsDeleted_,this),T(this.contactsDeleted_,this))
    }
    ;
    Q.contactsDeleted_=function(){
        this.choosePanel_()
    }
    ;
    Q.saveCurrentGroup_=function(){
        var a=$[C]("$TempGroup/Name")||"";
        a=je(a);
        var b=tp(this.contactData_,a,this.curGroupId_);
        if(b)ja(b);
        else{
            a=new bp(this.contactData_,this.curGroupId_,"RENAME",a,T(this.groupSaved_,this));
            a[pc]()
        }
    }
    ;
    Q.groupSaved_=function(){
        $[u]("$ContactManager/Panel","VIEW_GROUP")
    }
    ;
    Q.done_=function(){
        this[F](new Ig("DONE"))
    }
    ;
    Q.contactSelected_=function(a){
        var b=a.canPrevent!=k;
        sg&&mg&&b?S[yb](T(this.contactSelectedImpl_,this,a),100):this.contactSelectedImpl_(a)
    }
    ;
    Q.contactSelectedImpl_=function(a){
        var b=a.canPrevent!=k;
        if(!(b&&!this.nav_.canGoTo({
view:"VIEW_CONTACT"
                        }
                        ))){
            Uf.info("Starting contact select ("+this.dataManager_.getEventCount()+")");
            b=a.row;
            a.additional?this.contactData_.selectContact(b):this.contactData_.selectSingleContact(b);
            this.contactData_.associateGroupsToContact_(b);
            this.choosePanel_(k);
            Uf.info("Ending contact select")
        }
    }
    ;
    Q.underleavePersonalContact_=function(a){
        if(!a.areUnderleavedProfilesLoaded()){
            a.setAreUnderleavedProfilesLoaded(i);
            var b=this.dataManager_,c=function(f){
                for(var g=0;
                g<f[x];
                g++)a.addUnderleavedProfile(f[g]);
                b.fireDataChange("$CurrentContact");
                b.fireDataChange("$TempContact")
            }
            ,e=T(function(){
                this.setAreUnderleavedProfilesLoaded(k)
            }
            ,a);
            c=this.getDomainProfileSearchRequest_(a,c,e);
            c[pc]()
        }
    }
    ;
    Q.interleavePersonalContact_=function(a){
        if(!a.isInterleavedProfileDataLoaded()){
            a.setIsInterleavedProfileDataLoaded(i);
            var b=this.dataManager_,c=function(f){
                for(var g=0;
                g<f[x];
                g++)a.addProfileForInterleavedView(f[g]);
                b.fireDataChange("$CurrentContact");
                b.fireDataChange("$TempContact")
            }
            ,e=T(function(){
                this.setIsInterleavedProfileDataLoaded(k)
            }
            ,a);
            c=this.getDomainProfileSearchRequest_(a,c,e);
            c[pc]()
        }
    }
    ;
    Q.getDomainProfileSearchRequest_=function(a,b,c){
        return new Bp(this.contactData_,a,b,c)
    }
    ;
    Q.interleaveDomainContact_=function(a){
        if(a.isProfileLoaded())this.loadAndInterleaveDomainContact_(a);
        else{
            this.interleaveContactsWithDomainContact_(a);
            var b=T(function(){
                this.loadAndInterleaveDomainContact_(a)
            }
            ,this);
            b=this.getDomainContactProfileRequest_(a,T(this.loadAndInterleaveDomainContact_,this),b);
            b[pc]()
        }
    }
    ;
    Q.loadAndInterleaveDomainContact_=function(a){
        a.clearInterleavedData();
        this.interleaveContactsWithDomainContact_(a);
        this.loadAndInterleaveAllPrivateContacts_(a)
    }
    ;
    Q.getDomainContactProfileRequest_=function(a,b,c){
        return new Ap(this.contactData_,a,b,c)
    }
    ;
    Q.interleaveContactsWithDomainContact_=function(a){
        var b=this.contactData_.getPersonalContactsByPrimaryEmail(a.getEmail());
        if(b[x]>0){
            for(var c=0;
            c<b[x];
            c++)a.addProfileForInterleavedView(b[c]);
            this.dataManager_.fireDataChange("$CurrentContact")
        }
    }
    ;
    Q.loadAndInterleaveAllPrivateContacts_=function(a){
        if(!this.contactData_.allPrivateContactsLoaded()){
            var b="$ContactData/AppendRequestDone",c=T(function(){
                var e=$[C](b);
                if(e){
                    this.dataManager_.removeListeners(c,b);
                    this.interleaveContactsWithDomainContact_(a)
                }
            }
            ,this);
            this.dataManager_.addListener(c,b);
            this.contactData_[Eb](4,1E4)
        }
    }
    ;
    Q.contactMultipleSelected_=function(a){
        var b=a.rowList,c=a.down;
        if(b[x]>0)if(this.nav_.canGoTo({
view:"VIEW_CONTACT"
                    }
                    )){
            Uf.info("Starting contact multi select ("+this.dataManager_.getEventCount()+")");
            a=0;
            if(c)a=b[x]-1;
            c=i;
            if(this.contactList_.isSelected(b[a]))c=k;
            for(a=0;
            a<b[x];
            a++){
                this.contactData_.selectContact(b[a],c);
                this.contactData_.associateGroupsToContact_(b[a])
            }
            this.choosePanel_(k);
            Uf.info("Ending contact multi select")
        }
    }
    ;
    Q.contactSaved_=function(a){
        if(a.isNew&&this.contactData_.isGroupLocked($[C]("$CurrentGroup/id"))){
            var b=a.row&&this.contactData_.isContactInGroup(a.row,"^Mine")?"^Mine":"^Collect";
            this.selectGroup_(b,k)
        }
        if(a.isMerged){
            this.contactData_.unselectContacts();
            this.choosePanel_(k)
        }
        else this.contactSelected_(a)
    }
    ;
    Q.choosePanel_=function(a,b){
        var c=b||this.determineMainView_(),e=a==j?i:a;
        this.nav_.goTo({
view:c,canPrevent:e
        }
        )
    }
    ;
    Q.determineMainView_=function(){
        var a=this.contactData_.getSelectedContacts().getChildNodes(),b=a.getCount(),c=k;
        if(b==0){
            b="VIEW_GROUP";
            $[u]("$ContactManager/EnableGroupEdit",this.isGroupEditable_())
        }
        else{
            if(b==1){
                c=a.getByIndex(0).getChildNodeValue("Id");
                b=this.contactData_.getContact(c);
                b.refreshPicture();
                this.requestChatInformation_(c);
                if(this.contactData_.domainContactsEnabled()&&this.contactData_.isUserInExperiment("interleavedcontacts")){
                    if($[C]("$UserData/AspDomain"))b.isDomainContact()?this.interleaveDomainContact_(b):
                    this.interleavePersonalContact_(b)
                }
                else if(this.contactData_.domainContactsEnabled()&&this.contactData_.isUserInExperiment("underleavedcontacts")){
                    if($[C]("$UserData/AspDomain"))b.isDomainContact()?this.loadDomainContactProfile_(b):this.underleavePersonalContact_(b)
                }
                else b.isDomainContact()&&!b.isProfileLoaded()&&this.loadDomainContactProfile_(b);
                this.viewer_.setDataPath("$Contacts/"+c);
                b="VIEW_CONTACT"
            }
            else b="MULTIPLE_CONTACTS";
            $[u]("$ContactManager/EnableEdit",this.areContactsEditable_(a));
            $[u]("$ContactManager/EnableGroups",
            this.areContactsGroupable_(a));
            c=this.areContactsMoveToMineable_(a);
            $[u]("$ContactManager/EnableMoveToMine",c);
            $[u]("$ContactManager/EnableDelete",this.areContactsDeleteable_(a))
        }
        $[u]("$ContactManager/ShowMoveToMine",this.showMoveToMine_(c));
        $[u]("$ContactManager/ShowIgnore",this.showIgnore_());
        $[u]("$ContactManager/EnableMergeLink",this.showMergeLink_(a));
        $[u]("$ContactManager/EnableVoice",es());
        $[u]("$ContactManager/EnableVoiceSms",this.isVoiceSmsEnabled_());
        return b
    }
    ;
    Q.loadDomainContactProfile_=function(a,b,c){
        if(a.get()&&a.isDomainContact()){
            a=new Ap(this.contactData_,a,b,c);
            a[pc]()
        }
    }
    ;
    Q.isGroupEditable_=function(){
        var a=$[C]("$ContactManager/SearchActive"),b=$[C]("$CurrentGroup/IsSystem"),c=$[C]("$CurrentGroup/IsFfc"),e=$[C]("$ContactManagerConfig/ShowOldGc"),f=$[C]("$UserData/IsGcUser");
        b=!b;
        c=c&&e&&f;
        return!a&&(b||c)
    }
    ;
    var es=function(){
        var a=$[C]("$ContactManagerConfig/ShowVoice"),b=$[C]("$UserData/IsGcUser");
        return a&&b
    }
    ;
    Q=Yr[y];
    Q.isVoiceSmsEnabled_=function(){
        var a=$[C]("$ContactManagerConfig/ShowVoiceSms");
        return a&&es()
    }
    ;
    Q.areContactsEditable_=function(a){
        return a.getCount()==1&&!a.getByIndex(0).isDomainContact()
    }
    ;
    Q.areContactsDeleteable_=function(a){
        for(var b=0;
        b<a.getCount();
        b++)if(!a.getByIndex(b).isDomainContact())return i;
        return k
    }
    ;
    Q.areContactsMoveToMineable_=function(a){
        if(a.getCount()==0)return k;
        if(this.curGroupId_=="^Collect"&&!$[C]("$ContactManager/SearchActive",k))return i;
        for(var b=0;
        b<a.getCount();
        b++){
            var c=a.getByIndex(b),e=this.contactData_.isContactInGroup(c,"^Mine");
            c=c.isDomainContact();
            if(!e&&!c)return i
        }
        return k
    }
    ;
    Q.areContactsGroupable_=function(a){
        if(a.getCount()==0)return k;
        return i
    }
    ;
    Q.showMoveToMine_=function(a){
        var b=k;
        if(this.curGroupId_=="^Collect"||this.curGroupId_=="^All")b=i;
        else if($[C]("$ContactManager/SearchActive",k)||this.curGroupId_=="^Freq")b=a;
        return b
    }
    ;
    Q.showIgnore_=function(){
        return this.curGroupId_=="^Collect"
    }
    ;
    Q.showMergeLink_=function(a){
        var b=$[C]("$SelectedContactCount");
        if(b<=10){
            for(b=0;
            b<a.getCount();
            b++)if(a.getByIndex(b).isDomainContact())return k;
            return i
        }
        return k
    }
    ;
    Q.onNavigate_=function(a){
        a=a[gc];
        this.addContactAc_&&this.addContactAc_.dismiss();
        var b=$[C]("$ContactManager/Panel");
        if(a=="NON_EDIT_MODE")if(b=="EDIT_CONTACT")a=this.determineMainView_();
        else return;
        if(a!=b){
            $[u]("$ContactManager/Panel",a);
            $[u]("$ContactManager/Today",(new Date).toLocaleDateString());
            b=Z("manager-group-list");
            a=="VIEW_GROUP"||a=="HOME"?vi(b,"group-list-secondary"):ui(b,"group-list-secondary");
            b=Z("pagetable");
            a=="IMPORT"||a=="IMPORT_RESULTS"||a=="EXPORT"||a=="PRINT"||a=="FIND_DUPLICATES"?
            ui(b,"hide-contacts"):vi(b,"hide-contacts")
        }
        Sl()[ad]()
    }
    ;
    Q.onAllowNavigate_=function(){
        var a=$[C]("$ContactManager/Panel");
        return a=="EDIT_CONTACT"?p.confirm("Are you sure you want to stop editing this contact? Unsaved changes will be lost."):i
    }
    ;
    Q.contactsChanged_=function(){
        var a=this.contactData_.getChildNodes().getCount();
        if(a!=this.lastContactsCount_||this.buttonSearch_){
            this.lastContactsCount_=a;
            this.contactList_.recalculateData();
            this.addContactAc_&&this.addContactAc_[qc]()&&this.processAutocompleteMatches_()
        }
    }
    ;
    Q.loadRequestChange_=function(){
        var a=W("$ContactData/Loading").getValue(),b=W("$ContactData/PendingRequest").getValue(),c=new Ig("LOADING");
        c.requestLoading=a||b;
        Uk().doEvent(c)&&$[u]("$ContactData/ShowLoadingMessage",a)
    }
    ;
    var fs=function(a,b){
        if(p.csi_enabled){
            p[a]=new p.jstiming.Timer;
            Ua(p[a],b)
        }
    }
    ,gs=function(a){
        if(p.csi_enabled){
            p[a].tick("done");
            p.jstiming.report(p[a])
        }
    }
    ,ks=function(a,b){
        new Tk("Child");
        var c=V();
        c.addDataSource(new wk(b,"Manifest"));
        c.aliasDataSource("$Images","$Manifest/image");
        var e=Ki("div",{
id:"ContactManager"
        }
        );
        e[Pc]("maximize","true");
        e[Pc]("class","manager-page-holder");
        var f=q[Ib]("zgbfxt2z");
        (f||q[dc])[v](e);
        e=new Sh(q[Rb][Rc]);
        e=e.getQueryData();
        c.addDataSource(new wk(e.get("hl","en"),
        "Locale"));
        Zr=f=e.get("style","NORMAL");
        rp();
        $r=e.get("sk",k);
        Sk()[M]("load",T(hs,this,e));
        fs("__cmViewLoad","contact_view_load");
        for(f=0;
        f<b[gc][x];
        f++){
            var g=b[gc][f];
            tm().addXmlView(g)
        }
        fs("__cmDataLoad","contact_data_load");
        if(a!=j){
            Bm=a+"/ui/";
            f=Lm();
            X&&De(Bg,"8")<0?f.setMaxContacts(300):f.setUseInitialEmbeddedData(i);
            f.setUseGroups(i);
            f.setGetAllFields(i);
            f.setUseThumbs(i);
            f.setGetUserPrefs(k);
            f.setIncludeGrandCentral(i);
            g=e.get("dc","false")=="true";
            f.setSupportDomainContacts(g);
            f[Eb]();
            c.addListener(is,
            "$ContactData/Loaded")
        }
        else js();
        p.vman=tm();
        if(e.get("pop"))Zr="pop"
    }
    ,ls=function(a){
        var b=Lm();
        b.handleInitialEmbeddedData(a)
    }
    ,ms=function(a){
        var b={
        }
        ;
        b.ShowChatLink=i;
        b.ShowTitleBar=a.get("titleBar","false")=="true";
        b.ShowNavLinks=k;
        b.ShowEmailsLink=a.get("emailsLink",k);
        b.ShowVoice=a.get("showVoice",k)=="true";
        b.ShowVoiceSms=a.get("showVoiceSms",k)=="true";
        b.EnableRosterManagement=i;
        b.AllowIdn=a.get("idn","")=="true";
        var c=a.get("hl","en");
        b.Hl=c;
        b.GoogleProfileLink="http://www.google.com/profiles/me?hl="+
        c+"&edit=cm";
        c=V();
        c.addDataSource(new wk(b,"ContactManagerConfig"));
        b={
Panel:a.get("initialPanel","VIEW_GROUP")
        }
        ;
        var e=a.get("initialGroup");
        if(e&&he(e))b.InitialGroup=e;
        if((a=a.get("initialContact"))&&he(a))b.InitialContact=a;
        c.addDataSource(new wk(b,"ContactManager"))
    }
    ,ns=function(a,b){
        var c=new Sh(a);
        return c.setParameterValue("hl",b)[db]()
    }
    ,is=function(){
        var a=$[C]("$ContactData/Loaded");
        if(a){
            if((a=W("$UserData/Email").getValue())&&a[x]>0){
                a="Contact Manager - "+a;
                qa(q,a)
            }
            else qa(q,"Contact Manager");
            as&&Ll();
            Xr=i;
            os();
            if(!p.__cmDataLoadReported){
                gs("__cmDataLoad");
                p.__cmDataLoadReported=i
            }
        }
    }
    ,ps=function(a){
        return a.getDomain()=="mail.google.com"||be(a.getPath(),"/mail/")
    }
    ,os=function(){
        if(Xr&&bs){
            var a=Lm();
            if(!cs){
                var b=$[C]("$ContactManager/InitialGroup");
                b?ds.selectGroup_(b):ds.selectDefaultGroup_();
                a.isUserInExperiment("cmdomaincon")&&a.setSupportDomainContacts(i);
                if(b=a.domainContactsEnabled())mp=1E3;
                $[u]("$ContactManager/DomainContactsEnabled",b);
                b=b;
                var c=$[C]("$ContactManagerConfig/ShowTitleBar",
                k);
                if(c){
                    var e=b&&c?"td-search-input-dc":"td-search-input";
                    if(e=Z(e))Wa(e[H],"")
                }
                b=b&&c?"-set-token-dc":"-set-token";
                b=Z(ds.baseId_+b);
                ds.tokenEl_=b;
                Aa(b,i);
                ui(b[O],"disabled");
                ds.clearToken_();
                ds.initSearchListeners_();
                cs=i
            }
            if(ds.tokenEl_){
                Aa(ds.tokenEl_,k);
                vi(ds.tokenEl_[O],"disabled")
            }
            $[u]("$ContactManager/ChatSupportEnabled",ps(new Sh(p[Rb])));
            $[u]("$ContactManager/ExpShowGcuLink",a.isUserInExperiment("showgculink"));
            $[u]("$ContactManager/ExpPrimaryEmail",a.isUserInExperiment("primaryemail"));
            $[u]("$ContactManager/MergeQueuePhase1",a.isUserInExperiment("mergequeuephase1"));
            $[u]("$ContactManager/ExpInterleavedContacts",a.domainContactsEnabled()&&a.isUserInExperiment("interleavedcontacts"));
            $[u]("$ContactManager/ExpUnderleavedContacts",a.domainContactsEnabled()&&a.isUserInExperiment("underleavedcontacts"));
            $[u]("$ContactManager/ExpNewSectionHeaderOrder",a.domainContactsEnabled()&&a.isUserInExperiment("newsectionheaderorder"));
            $[u]("$ContactManager/ShowFooter",(es()||!ps(new Sh(p[Rb])))&&
            a.isUserInExperiment("showfooter"));
            b=new Sh(q[Rb][Rc]);
            if(b=b.getPath()[nc](/\/a\/google.com\/contacts\/ui\//)?b.resolve(new Sh("/a/c/google.com/ui/")):j){
                        $[u]("$ContactManager/ExpOrganizer",a.isUserInExperiment("contactorganizer"));
                        $[u]("$ContactManager/ExpWhoDoIKnow",a.isUserInExperiment("whodoiknow"));
                        $[u]("$ContactManager/ContactOrganizerUrl",b[db]()+"ContactOrganizer");
                        $[u]("$ContactManager/WhoDoIKnowUrl",b[db]()+"WhoDoIKnow")
                    }
                    a=$[C]("$ContactReq/Body/CustomizedHelpUrl");
                    b=$[C]("$ContactManagerConfig/Hl");
                    $[u]("$ContactManagerConfig/GroupsHelpLink",ns(a,b));
                    a=$.getNode("$ExtraData/NavLinks",i);
                    if(Z("additional-nav-links")&&a){
            xa(Z("additional-nav-links"),a.get());
            a=$.getNode("$ExtraData/BlInfo",i);
            qa(Z("additional-nav-links"),a.get())
        }
        Uk().doEvent(new Ig("READY"));
        a="__cmFull";
        if(p.csi_enabled){
            b=p[a];
            b.tick("plt");
            b.tick("aft");
            p.jstiming.report(p[a])
        }
    }
}
,hs=function(a){
    ms(a);
    a=Wl().getServerBase()[db]();
    var b=Z("ContactManager");
    $a(b[H],"hidden");
    tm().renderView("ContactManager",b,j,{
ServerBase:a,
ThumbSize:64
    }
    );
    a=new Yr("$Contacts","$Groups","$AuthToken",this.contactData_,Wl().getServerBase()+"/static/",Wl().getServerBase()+"/update/",Zr);
    Zr=="pop"&&Y(a,"DONE",function(){
        p[ac]()
    }
    );
    ds=a;
    Hd("ContactManager",a,void 0);
    Hm();
    $r||a.makeVisible_();
    bs=i;
    Uk().doEvent(new Ig("VIEW_READY"));
    gs("__cmViewLoad");
    os()
};
Yr[y].makeVisible_=function(){
    Ll();
    Y(S,"resize",Ml);
    var a=Z("ContactManager");
    $a(a[H],"visible");
    as=i
};
Yr[y].onMakeVisible_=function(){
    if(bs)this.makeVisible_();
    else $r=k
};
var qs=function(){
};
U(qs,Xj);
qs[y].renderRow=function(a,b,c){
    xa(c,se(a[Bb][db](b)))
};
qs[y].render=Wj.render;
Q=Yr[y];
Q.requestMatchingRows=function(a,b,c){
    this.curAutocompleteToken_=a;
    this.matchHandler_=c;
    b=this.processAutocompleteMatches_();
    a&&b[x]<10&&S[yb](T(this.maybeGetMoreContacts_,this,a),1E3)
};
Q.maybeGetMoreContacts_=function(a){
    a==this.curAutocompleteToken_&&Lm()[Eb](4,20,a,i)
};
Q.processAutocompleteMatches_=function(){
    var a=[],b=this.curAutocompleteToken_;
    if(b!=""){
        for(var c=new gp(b,k,i),e=new hp(b),f=this.contactData_.getChildNodes(),g=0;
        g<f.getCount();
        g++){
            var h=f.getByIndex(g),n=c;
            if(h.isDomainContact())n=e;
            n[nc](h)&&!this.contactData_.isContactInGroup(h,this.curGroupId_)&&!h.isDomainContact()&&a[w](h)
        }
        a[Mc](function(o,s){
            return s.getAffinity()-o.getAffinity()
        }
        );
        if(a[x]>10)pa(a,10)
    }
    this.matchHandler_(b,a);
    return a
};
Q.contactListChanged_=function(){
    var a=this.contactList_.getToken();
    if(a){
        if($[C]("$ContactManager/SearchToken")!=a){
            this.contactData_.unselectContacts();
            this.choosePanel_(k);
            $[u]("$ContactManager/SearchToken",a)
        }
        this.groupList_.selectGroup("^Results");
        $[u]("$ContactManager/SearchActive",i);
        a=this.contactList_.getVisibleCount();
        $[u]("$ContactManager/SearchCount",a);
        if(a==1&&this.selectSingleSearchResultOnce_){
            this.contactData_.selectSingleContact(this.contactList_.getVisibleRows()[0]);
            this.choosePanel_(k);
            this.selectSingleSearchResultOnce_=k
        }
    }
    else{
        this.groupList_.selectGroup(this.curGroupId_);
        $[u]("$ContactManager/SearchActive",k);
        $[u]("$ContactManager/SearchToken",j)
    }
};
Q.contactListRendered_=function(){
    this.contactList_.scrollToFirstMatchingRow(this.contactData_.getSelectedContacts().getChildNodes())
};
Q.moveCurrentContactToMineGroup_=function(){
    var a=new Ig("ADD_CONTACT_TO_GROUP");
    a.contactId=W("$CurrentContact/id").getValue();
    a.groupId="^Mine";
    a.selectGroup=i;
    Sk()[Oc](a)
};
Q.ignoreSuggestions_=function(){
    this.contactData_.ignoreSelectedContactsAsSuggestions(T(this.afterSuggestionsIgnored_,this),j)
};
Q.afterSuggestionsIgnored_=function(){
    this.contactList_.recalculateData();
    this.choosePanel_()
};
var rs=function(a){
    this.addCallback_=a;
    tj[J](this,",;
",'"')
};
U(rs,tj);
rs[y].selectRow=function(a){
    var b=W("$CurrentGroup/id").getValue(),c=Lm();
    if(c.isGroupGrowable(b)){
        a=new Dp(c,[a.getChildNodeValue("Id")],b,"ADD",j,this.addCallback_);
        a[pc]()
    }
    if(this.ac_.getTarget()){
        za(this.ac_.getTarget(),"");
        this.ac_.getTarget()[zc]()
    }
};
rs[y].attachInputs=function(){
    rs.superClass_.attachInputs[$c](this,arguments);
    for(var a=0;
    a<arguments[x];
    a++){
        var b=arguments[a];
        Y(b,"keypress",function(c){
            var e=c[Dc];
            e==13&&c[Sb]()
        }
        )
    }
};
Yr[y].refreshGroupMenu_=function(a){
    for(var b=W("$Groups/*").getNodes(),c=Lm(),e=c.getSelectedContacts().getChildNodes(),f=a.getMenu();
    f.getItemCount()>0;
    )f.removeItemAt(0);
    var g=[],h=[],n={
    }
    ,o={
    }
    ,s=k;
    a.setScrollOnOverflow(i);
    for(a=0;
    a<e.getCount();
    a++){
        for(var A=e.getByIndex(a),G=0;
        G<b.getCount();
        G++){
            var R=b.getByIndex(G),L=R.getChildNodeValue("id");
            if(!c.isGroupLocked(R))if(c.isContactInGroup(A,L)){
                if(!n[L]){
                    h[w](R);
                    n[L]=i
                }
            }
            else if(!o[L]){
                g[w](R);
                o[L]=i
            }
        }
        if(!s&&c.isContactInGroup(A,"^Mine"))s=
        i
    }
    if(s){
        c="^Mine";
        (b=b.get(c))&&h[w](b)
    }
    this.createGroupHeaderItem_(f,"<b>Add to...</b>");
    this.createGroupMenuItem_(f,"New group...","^New","ADD_CONTACT_TO_GROUP");
    for(a=0;
    a<g[x];
    a++){
        R=g[a];
        b=se(R.getChildNodeValue("Name"));
        L=R.getChildNodeValue("id");
        this.createGroupMenuItem_(f,b,L,"ADD_CONTACT_TO_GROUP")
    }
    if(h[x]>0){
        this.createGroupHeaderItem_(f,"<b>Remove from...</b>");
        for(a=0;
        a<h[x];
        a++){
            R=h[a];
            b=se(R.getChildNodeValue("Name"));
            L=R.getChildNodeValue("id");
            this.createGroupMenuItem_(f,b,L,"REMOVE_CONTACT_FROM_GROUP")
        }
    }
    Y(f,
    "action",this.onGroupAction_,k,this)
};
Yr[y].createGroupMenuItem_=function(a,b,c,e){
    c=[c,e];
    e=Ki("span");
    xa(e,b);
    b=new Xn(e,c);
    a.addItem(b);
    b.setEnabled(i)
};
Yr[y].createGroupHeaderItem_=function(a,b){
    var c;
    c=Ki("span");
    xa(c,b);
    c=new Xn(c);
    a.addItem(c);
    c.addClassName("section");
    c.setEnabled(k)
};
Yr[y].onGroupAction_=function(a){
    var b=a[I].getValue();
    if(b){
        a=b[0];
        b=b[1];
        b=new Ig(b);
        b.contactId=W("$CurrentContact/id").getValue();
        b.groupId=a;
        Sk()[Oc](b)
    }
};
Hd("decorateActionControl",ho,void 0);
Hd("handleInitialContactData",ls,void 0);
Hd("initContactManager",ks,void 0);
En("goog-menu-button",function(){
    return new eo(j)
}
);
var ts=function(a,b,c,e,f,g,h,n,o){
    ss||(ss=Of("goog.focus.ContactPicker"));
    this.hasContacts_=k;
    this.baseId_=h||"picker";
    this.staticRoot_=f;
    this.updateRoot_=g;
    this.contactDataPath_=a;
    this.groupsDataPath_=b;
    this.fsidExpr_=W(c+"/Value");
    this.dataExpr_=W(this.contactDataPath_+"/*");
    this.targetGroupExpr_=W("Groups/^Temp");
    this.contactsDs_=e;
    b=V();
    b.addListener(T(this.gotGroups_,this),this.groupsDataPath_);
    b.addListener(T(this.gotContacts_,this),this.contactDataPath_);
    b.addListener(T(this.groupChange_,
    this),"$ContactPicker/CurrentGroup");
    b.addListener(T(this.loadReqChange_,this),"$ContactData/PendingLongRequest");
    b.addListener(T(this.loadReqChange_,this),"$ContactData/Loading");
    this.srcEl_=Z(this.baseId_+"-src");
    this.targetEl_=Z(this.baseId_+"-target");
    this.targetHolderEl_=Z(this.baseId_+"-target-holder");
    this.addContactEl_=Z(this.baseId_+"-add-contact");
    this.spinnerEl_=Z(this.baseId_+"-spinner");
    this.reqSpinnerEl_=Z(this.baseId_+"-req-spinner");
    this.groupChooserSelect_=Z(this.baseId_+"-group-chooser");
    if(this.addContactEl_){
        Wa(this.addContactEl_[H],"none");
        this.mouseOverTarget_=this.addContactElFocus_=k;
        Y(this.targetHolderEl_,"mouseover",function(){
            this.mouseOverTarget_=i;
            this.syncTargetHolderFocus_()
        }
        ,i,this);
        Y(this.targetHolderEl_,"mouseout",function(){
            this.mouseOverTarget_=k;
            this.syncTargetHolderFocus_()
        }
        ,i,this);
        Y(this.targetHolderEl_,"click",function(){
            this.focusAddContactEl_()
        }
        ,k,this);
        Y(this.addContactEl_,"focus",function(){
            this.addContactElFocus_=i;
            this.syncTargetHolderFocus_()
        }
        ,k,this);
        Y(this.addContactEl_,"blur",function(){
            this.addContactElFocus_=k;
            Wa(this.addContactEl_[H],"none");
            this.syncTargetHolderFocus_()
        }
        ,k,this);
        c=new El(this.addContactEl_);
        Y(c,"ENTER",this.tryAddContact_,i,this)
    }
    this.targetType_=n?n:Qe(ti(this.targetEl_),"picture-list")?"PICTURE":"TO_LIST";
    if(o)this.tempTitle_=o;
    n={
    }
    ;
    n.MANUAL_ROWSET=i;
    this.srcList_=new Qr(this.srcEl_,a,n,"NONE",this.staticRoot_);
    this.srcList_.setHideNoEmail(i);
    this.srcList_.setSelectedGroup("^Temp");
    if(this.targetEl_){
        if(this.targetType_==
                "TO_LIST"){
            n={
            }
            ;
            n.ELEMENT_NAME="span";
            n.ROOT_ELEMENT_NAME="span";
            n.MANUAL_ROWSET=k;
            n.FIXED_HEIGHT=k;
            this.targetList_=new Pr(this.targetEl_,"$SelectedContacts",n);
            this.targetList_.renderRow=function(s,A){
                var G=s.getDisplayName();
                if(!G)(G=s.getEmail())||(G=s.getNameForDisplay());
                G=se(G);
                G+=", ";
                xa(A,G)
            }
        }
        else this.targetList_=new Qr(this.targetEl_,a,"ACTION_SELECT_TOGGLE",this.staticRoot_);
        this.targetList_.setSelectedGroup("^Temp");
        this.targetList_.setGroup("^Temp")
    }
    this.doneEl_=Z(this.baseId_+"-done");
    this.cancelEl_=Z(this.baseId_+"-cancel");
    this.manageEl_=Z(this.baseId_+"-manage");
    this.saveGroupEl_=Z(this.baseId_+"-save-group");
    this.doneEl_&&Y(this.doneEl_,"click",this.done_,k,this);
    this.cancelEl_&&Y(this.cancelEl_,"click",this.cancel_,k,this);
    this.manageEl_&&Y(this.manageEl_,"click",this.manage_,k,this);
    this.saveGroupEl_&&Y(this.saveGroupEl_,"click",this.saveGroup_,k,this);
    this.messageUi_=new Tl(this.baseId_+"-messages");
    Y(this.srcList_,"SELECT",this.contactSelected_,k,this);
    Y(this.targetList_,
    "SELECT",this.contactSelected_,k,this);
    Y(this.srcList_,"LIST_CHANGED",this.contactListChanged_,k,this);
    Y(S,"unload",this.unload_,k,this);
    this.tokenEl_=Z(this.baseId_+"-token");
    this.attachToTokenInput_(this.tokenEl_);
    this.state_={
    }
    ;
    a=new wk(this.state_,"ContactPicker");
    b.addDataSource(a,i);
    $[u]("$ContactPicker/CurrentGroup","^Freq");
    (this.groupNameEl_=Z(this.baseId_+"-group-name"))&&ql(this.groupNameEl_,"optional: name this group");
    this.addAllEl_=Z(this.baseId_+"-add-all");
    this.enableLink_(this.addAllEl_,
    this.addAll_,k);
    this.removeAllEl_=Z(this.baseId_+"-remove-all");
    this.enableLink_(this.removeAllEl_,this.removeAll_,k)
}
,ss;
mf(ts[y],uh[y]);
Q=ts[y];
Q.unload_=function(){
    ph()
};
Q.allContacts=function(){
    return this.dataExpr_.getNodes()
};
Q.contactSelected_=function(a){
    Lm().selectContact(a.row);
    this.afterContactSelected_()
};
Q.afterContactSelected_=function(){
    var a=Lm().getSelectedContacts().getChildNodes().getCount();
    V().fireDataChange("$SelectedContacts");
    var b=Z(this.baseId_+"-target-title");
    if(b)xa(b,this.groupTitle_("^Temp"));
    this.enableLink_(this.removeAllEl_,this.removeAll_,a>0)
};
Q.contactListChanged_=function(){
    this.recalcVisible_();
    var a=W("$ContactPicker/CurrentGroup").getValue();
    if(this.srcList_.getToken()){
        if(a!="^Results"){
            this.lastGroupId_=a;
            $[u]("$ContactPicker/CurrentGroup","^Results")
        }
        this.updateSearchResultCount_()
    }
    else if(a=="^Results"&&this.lastGroupId_){
        for(a=0;
        this.groupChooserSelect_[tc][a];
        ++a){
            var b=this.groupChooserSelect_[tc][a];
            if(b[D]==this.lastGroupId_){
                sa(this.groupChooserSelect_,b.index);
                break
            }
        }
        $[u]("$ContactPicker/CurrentGroup",this.lastGroupId_)
    }
};
Q.updateSearchResultCount_=function(){
    if(this.resultOptionEl_){
        var a=$[C]("$ContactPicker/VisibleContactCount");
        a="Search Results ("+(a+")");
        ua(this.resultOptionEl_,a)
    }
};
Q.attachToTokenInput_=function(a){
    if(a){
        this.tokenEl_=a;
        mp=100;
        a=lp(this.srcList_,a,i);
        a.setPauseTime(500)
    }
};
Q.groupName_=function(a){
    if(a=="^Temp"){
        a=this.tempTitle_||"To:";
        return a+" "
    }
    else return W(this.groupsDataPath_+"/"+a+"/Name").getValue()
};
Q.groupTitle_=function(a){
    var b;
    b=this.allContacts();
    var c=a;
    if(c=="^Temp"){
        for(var e=0,f=0;
        f<b.getCount();
        f++){
            var g=b.getByIndex(f);
            Lm().isContactInGroup(g,c)&&e++
        }
        b=e
    }
    else b=(b=W("$Groups/"+c).getNode())?b.getChildNodeValue("Count"):0;
    b=b?" ("+b+")":"";
    return this.groupName_(a)+b
};
Q.groupChange_=function(){
    var a=W("$ContactPicker/CurrentGroup").getValue();
    if(a=="^Results"){
        if(!this.resultOptionEl_){
            this.resultOptionEl_=new Option("","^Results",k,k);
            a=this.groupChooserSelect_[tc][x];
            this.groupChooserSelect_[tc][a]=this.resultOptionEl_;
            sa(this.groupChooserSelect_,this.resultOptionEl_.index)
        }
    }
    else{
        if(this.resultOptionEl_){
            this.groupChooserSelect_[wc](this.resultOptionEl_.index);
            this.resultOptionEl_=j
        }
        if(a=="^All"||a=="^Collect")Lm()[Eb](3,1E4);
        this.srcList_.setGroup(a);
        if(this.srcList_.getToken()){
            this.srcList_.setToken("");
            wl(this.tokenEl_)
        }
        var b=Z(this.baseId_+"-src-title");
        if(b)xa(b,this.groupTitle_(a))
    }
};
Q.gotContacts_=function(){
    ss.info("Got contacts");
    if(!this.inGotContacts_){
        this.inGotContacts_=i;
        if(!this.hasContacts_){
            this.hasContacts_=i;
            ss.info("Got contacts");
            $[u]("$ContactPicker/CurrentGroup","^Freq");
            this.srcList_.invalidate();
            this.targetList_.invalidate()
        }
        this.inGotContacts_=k;
        var a=Z(this.baseId_+"-target-title");
        if(a)xa(a,this.groupTitle_("^Temp"));
        if(!this.defaultTextIsSet_){
            a="Search";
            if(Lm().domainContactsEnabled()){
                W("$UserData/AspDomainTitle").getValue();
                a="Search"
            }
            ql(this.tokenEl_,
            a);
            this.defaultTextIsSet_=i
        }
        this.srcList_.recalculateData()
    }
};
Q.gotGroups_=function(){
    ss.info("Got groups");
    if(this.groupChooserSelect_){
        for(var a=$.getNode(this.groupsDataPath_),b=W("$ContactPicker/CurrentGroup").getValue(),c=this.groupChooserSelect_[tc][x]==0,e=0;
        e<a.getChildNodes().getCount();
        e++){
            var f=a.getChildNodes().getByIndex(e);
            f=f.getChildNodeValue("id");
            var g=q[K]("option");
            za(g,f);
            ua(g,this.groupTitle_(f));
            this.groupChooserSelect_[tc][e]=g;
            if(b==f)ya(g,i)
        }
        c&&Y(this.groupChooserSelect_,"change",this.groupSelected_,k,this)
    }
};
Q.groupSelected_=function(){
    var a=W("$ContactPicker/CurrentGroup").getValue(),b=this.groupChooserSelect_[D];
    a!=b&&$[u]("$ContactPicker/CurrentGroup",b)
};
Q.loadReqChange_=function(){
    var a=W("$ContactData/PendingLongRequest").getValue()||W("$ContactData/Loading").getValue();
    Qj(this.reqSpinnerEl_,a)
};
Q.recalcVisible_=function(){
    var a=this.srcList_.getVisibleCount();
    $[u]("$ContactPicker/VisibleContactCount",a);
    this.enableLink_(this.addAllEl_,this.addAll_,a>0&&a<250)
};
Q.addAll_=function(a){
    for(var b=this.allContacts(),c=b.getCount(),e=this.srcList_,f=0;
    f<c;
    f++){
        var g=b.getByIndex(f);
        e.shouldRenderRow(g)&&Lm().selectContact(g,i)
    }
    this.afterContactSelected_();
    a&&a[Sb]()
};
Q.removeAll_=function(a){
    Lm().unselectContacts();
    this.afterContactSelected_();
    a&&a[Sb]()
};
Q.focusAddContactEl_=function(){
    if(this.addContactEl_){
        Wa(this.addContactEl_[H],"");
        this.addContactEl_[zc]()
    }
};
Q.syncTargetHolderFocus_=function(){
    if(this.targetHolderEl_)this.addContactElFocus_||this.mouseOverTarget_?ui(this.targetHolderEl_,"focused"):vi(this.targetHolderEl_,"focused")
};
Q.tryAddContact_=function(){
    var a=this.addContactEl_[D],b=k;
    if(ol(a)){
        a={
Emails:[{
Address:a
            }
            ]
        }
        ;
        a=new wk(a);
        b=Lm();
        a=b.addContact(a);
        b.selectContact(a);
        this.afterContactSelected_();
        za(this.addContactEl_,"");
        b=i
    }
    else ja("This doesn't appear to be a valid email.");
    Wa(this.addContactEl_[H],"");
    this.addContactEl_[zc]();
    return b
};
Q.done_=function(){
    if(this.addContactEl_[D]){
        var a=this.tryAddContact_();
        if(!a)return
    }
    this[F](new Ig("DONE"))
};
Q.cancel_=function(){
    this[F](new Ig("CANCEL"))
};
Q.manage_=function(){
    this[F](new Ig("MANAGE"))
};
Q.saveGroup_=function(){
    if(this.addContactEl_[D]){
        var a=this.tryAddContact_();
        if(!a)return
    }
    a=ap(Lm());
    if(a!=j){
        Wa(this.spinnerEl_[H],"block");
        a=new bp(Lm(),j,"NEW",a,T(this.saveGroupComplete_,this),T(this.saveGroupComplete_,this));
        a[pc]()
    }
};
Q.saveGroupComplete_=function(){
    Wa(this.spinnerEl_[H],"none")
};
var us=function(a){
    new sl(Z("picker-save-group"),"$SelectedContactCount>0");
    new sl(Z("picker-manage"));
    new sl(Z("picker-cancel"));
    new sl(Z("picker-done"));
    new rl(Z("picker-token"),a+"/static/images/SearchIcon.png"," ")
}
,ws=function(a){
    qa(q,"Contact Picker");
    new Tk("Child");
    var b=new Sh(q[Rb][Rc]),c=b.getQueryData(),e=c.get("tempTitle");
    if(e)e=se(e);
    b=c.get("inputId");
    var f=c.get("format","FULL"),g=c.get("done"),h=c.get("dm")=="goog",n=c.get("thumb")!=j?c.get("thumb"):i,o=c.get("width");
    c=c.get("height");
    if(h)q.domain="google.com";
    us(a);
    rp();
    var s;
    if(a!=j){
        h=Lm();
        h.setUseInitialEmbeddedData(i);
        h.setUseGroups(i);
        h.setFieldsToRequest("PICKER");
        h.setUseThumbs(n);
        h.setSupportDomainContacts(i);
        h.setSupportDomainGroups(i);
        n=X?100:300;
        h.setMaxContacts(n);
        h.setRequiredFields(["Emails"]);
        h[Eb]();
        s=h
    }
    else s=js();
    a=new ts("$Contacts","$Groups","$AuthToken",s,a+"/static/",a+"/update/",j,j,e);
    n=Gi(p);
    if(o>0&&c>0&&n[z]>0&&n[P]>0){
        e=o/n[z];
        n=c/n[P];
        e=r.min(3,r.max(1,e));
        n=r.min(3,r.max(1,n));
        e!=1&&n!=1&&p.resizeTo(e*
        o,n*c)
    }
    Y(p,"resize",vs);
    vs();
    if(b){
        var A=p.opener||p[ic],G=a.getInputElement_(A,b);
        if(!G&&b=="to_compose")if(b=="to_compose")G=a.getInputElement_(A,"../main/v2/to_compose");
        G?s.parseContactsAfterLoad(G[D]):ss.info("Could not find input element "+b);
        Y(a,"DONE",function(){
            if(G)za(G,s.formatContacts("^Temp",f));
            g?A[yb](A[g],10):p[ac]()
        }
        );
        Y(a,"CANCEL",function(){
            g?A[yb](A[g],10):p[ac]()
        }
        )
    }
};
ts[y].getInputElement_=function(a,b){
    for(var c=b[Fb]("/"),e=0;
    e<c[x]-1&&a;
    ++e)a=c[e]==".."?a[ic]:a[Ad][c[e]];
    if(!a)return j;
    var f=new wi(a[Ab]);
    return f.$(c[e])
};
ts[y].enableLink_=function(a,b,c){
    if(a){
        var e=!Qe(ti(a),"disabled");
        if(c!=e)if(c){
            vi(a,"disabled");
            Y(a,"click",b,k,this)
        }
        else{
            ui(a,"disabled");
            ph(a,"click")
        }
    }
};
var xs=function(a){
    var b=Lm();
    b.handleInitialEmbeddedData(a)
};
Hd("handleInitialContactData",xs,void 0);
Hd("initContactPicker",ws,void 0);
var vp=function(){
    var a=[{
id:"^Mine",Name:"My Contacts"
    }
    ,{
id:"^Freq",Name:"Most Contacted"
    }
    ,{
id:"ER",Name:"'ER' Dudes"
    }
    ,{
id:"Z",Name:"Z Other Group"
    }
    ];
    return new wk(a,"Groups")
}
,vs=function(){
    var a=Gi(p);
    if(mg)if(a[z]>p.outerWidth)ta(a,p.outerWidth);
    var b=a[z]-12;
    a=a[P]-10;
    if(X){
        b-=11;
        a+=4
    }
    var c=Z("main");
    c&&Lj(c,b,a);
    c=Z("picker-src");
    b=Z("picker-target")[O];
    Lj(c,1,160);
    Lj(b,1,40);
    var e=Mj(c[O][O]);
    a=Mj(b[O][O]);
    e.width+=7;
    Lj(c,e);
    c=Mj(c[O][O]);
    ta(a,c[z]-16);
    a.height-=10;
    Lj(b,a)
}
,js=function(){
    var a=
    new Sh(q[Rb][Rc]);
    a=a.getQueryData();
    var b=a.get("Prod",k);
    b=b?"contacts":"ccontacts";
    b=p.contactServer+b+"/";
    var c=a.get("Thumbs",i);
    a=a.get("Groups",k);
    return wp(b,c,a)
};
var Wr=function(){
    this.uiData_={
    }
    ;
    V().addDataSource(new wk(this.uiData_,"ContactViewer"));
    V().addDataSource(new wk(-1,"$CurrentContactId"));
    this.tempContactExpr_=W("$TempContact");
    var a=Sk();
    a[M]("SAVE_EDIT_CONTACT",T(this.handleSave_,this));
    a[M]("DELETE_PHOTO",T(this.handleDeletePhoto_,this))
};
mf(Wr[y],uh[y]);
Q=Wr[y];
Q.setDataPath=function(a){
    if(a!=this.dataPath_){
        this.dataPath_=a;
        this.expr_=W(this.dataPath_);
        $[u]("$CurrentContactId",this.expr_.getNode().getChildNodeValue("Id"));
        V().aliasDataSource("$CurrentContact",a);
        p.imageChanged=T(this.imageChanged_,this)
    }
    Lm().createTempContact(a)
};
Q.handleSave_=function(){
    var a=this.tempContactExpr_.getNode(),b=!a.getChildNodeValue("Id"),c=!!a.mergeIds_;
    Lm().saveContact(a,T(this.saveComplete_,this,b,c))
};
Q.handleDeletePhoto_=function(){
    Lm().deletePhoto(this.tempContactExpr_.getNode().getChildNodeValue("Id"))
};
Q.saveComplete_=function(a,b,c){
    var e=new Ig("ContactViewer.CONTACT_SAVED");
    e.row=c;
    e.canPrevent=k;
    e.isNew=a;
    e.isMerged=b;
    this[F](e)
};
Q.imageChanged_=function(){
    ja("This would change the picture")
};
var ys=function(a,b,c){
    this.isContact_=c;
    this.gcSettingsPhonesExpr_=W(a+"/ForwardingPhones/*");
    this.gcProfilePhonesExpr_=W(b+"/ForwardingPhones/*");
    this.directConnectExpr_=W(a+"/DirectConnect");
    this.directConnectOnElement_=Z("direct_connect_on");
    this.directConnectOffElement_=Z("direct_connect_off");
    b=this.directConnectExpr_.getValue();
    va(this.directConnectOnElement_,b);
    va(this.directConnectOffElement_,!b);
    Y(this.directConnectOnElement_,"click",T(this.directConnectChanged_,this),k,this);
    Y(this.directConnectOffElement_,
    "click",T(this.directConnectChanged_,this),k,this);
    if(this.isContact_){
        this.gcResponseExpr_=W(a+"/Response");
        this.gcModeExpr_=W(a+"/Mode");
        this.callForwardElement_=Z("call_action_forward");
        this.callNoForwardElement_=Z("call_action_no_forward");
        this.callResponseElement_=Z("response_name");
        this.groupSettingsElement_=Z("call_settings_group");
        this.customSettingsElement_=Z("call_settings_custom");
        this.groupSelectorElement_=Z("group_selector");
        this.customDivElement_=Z("settings_custom");
        a=this.gcModeExpr_.getValue();
        va(this.groupSettingsElement_,a!="CUSTOM");
        va(this.customSettingsElement_,a=="CUSTOM");
        Qj(this.customDivElement_,a=="CUSTOM");
        if(this.groupSelectorElement_)Aa(this.groupSelectorElement_,a=="CUSTOM");
        a=this.gcResponseExpr_.getValue();
        va(this.callForwardElement_,a=="DEFAULT");
        va(this.callNoForwardElement_,a!="DEFAULT");
        this.disableForwarding_(a!="DEFAULT");
        this.dataChanged_();
        this.modeChanged_();
        Y(this.groupSettingsElement_,"click",T(this.modeChanged_,this),k,this);
        Y(this.customSettingsElement_,"click",
        T(this.modeChanged_,this),k,this);
        Y(this.callForwardElement_,"click",T(this.callActionChanged_,this),k,this);
        Y(this.callNoForwardElement_,"click",T(this.callActionChanged_,this),k,this)
    }
    else this.dataChanged_()
};
Q=ys[y];
Q.callActionChanged_=function(){
    var a=this.callForwardElement_[wb];
    if(a){
        $[u](this.gcResponseExpr_.getSource(),"DEFAULT");
        this.disableForwarding_(k)
    }
    else{
        $[u](this.gcResponseExpr_.getSource(),"VOICEMAIL");
        this.disableForwarding_(i)
    }
};
Q.modeChanged_=function(){
    var a=this.customSettingsElement_&&this.customSettingsElement_[wb];
    $[u](this.gcModeExpr_.getSource(),a?"CUSTOM":"GROUP");
    if(this.groupSelectorElement_)Aa(this.groupSelectorElement_,a);
    Qj(this.customDivElement_,a)
};
Q.directConnectChanged_=function(){
    var a=this.directConnectOnElement_&&this.directConnectOnElement_[wb];
    $[u](this.directConnectExpr_.getSource(),a?i:k)
};
Q.dataChanged_=function(){
    var a=this.gcProfilePhonesExpr_.getNodes(),b=this.gcSettingsPhonesExpr_.getNodes(),c=k;
    if(this.isContact_){
        c=this.gcResponseExpr_.getValue();
        c=c!="DEFAULT"
    }
    this.phoneLogic_(c,a.getCount(),b)
};
Q.disableForwarding_=function(a){
    for(var b=this.gcProfilePhonesExpr_.getNodes().getCount(),c=0;
    c<b;
    c++){
        var e=zi("ForwardingCheckbox-["+c+"]");
        if(e)Aa(e,a)
    }
    Aa(this.callResponseElement_,!a)
};
Q.phoneLogic_=function(a,b,c){
    for(var e=0;
    e<b;
    e++){
        var f=zi("ForwardingCheckbox-["+e+"]");
        if(f){
            Aa(f,a);
            var g=f[D];
            va(f,k);
            for(var h=0;
            h<c.getCount();
            h++){
                var n=c.getByIndex(h).get();
                if(g==n)va(f,i)
            }
        }
    }
};
var zs=function(a,b,c){
    this.isContact_=c;
    this.gcSettingsExpr_=W(a);
    this.gcSettingsPhonesExpr_=W(a+"/ForwardingPhones/*");
    this.gcSettingsGreetingIdExpr_=W(a+"/GreetingId");
    this.gcProfilePhonesExpr_=W(b+"/ForwardingPhones/*");
    this.gcProfileGreetingsExpr_=W(b+"/Greetings/*");
    V().addListener(T(this.refresh_,this),a+"/ForwardingPhones");
    this.refresh_()
};
zs[y].refresh_=function(){
    var a=this.gcSettingsExpr_.getNode();
    if(a&&this.isContact_){
        if("CUSTOM"==a.getChildNodeValue("Mode")){
            this.greetingDisplay_();
            "DEFAULT"==a.getChildNodeValue("Response")&&this.forwardingDisplay_()
        }
    }
    else if(a&&!this.isContact_){
        this.forwardingDisplay_();
        this.greetingDisplay_()
    }
};
zs[y].forwardingDisplay_=function(){
    for(var a=this.gcProfilePhonesExpr_.getNodes(),b=this.gcSettingsPhonesExpr_.getNodes(),c=[],e=0;
    e<a.getCount();
    e++)for(var f=a.getByIndex(e),g=f.getChildNodeValue("Number"),h=0;
    h<b.getCount();
    h++){
        var n=b.getByIndex(h).get();
        n==g&&c[w](f.getChildNodeValue("Name"))
    }
    a="None (Send to Voicemail)";
    if(c[x]>0)a=c[ud](", ");
    (c=Z("forwarding_phones_display"))&&Wi(c,a)
};
zs[y].greetingDisplay_=function(){
    var a=this.gcSettingsGreetingIdExpr_.getNode(),b="0";
    if(a)b=a.get();
    var c=this.gcProfileGreetingsExpr_.getNodes();
    a="Default Greeting";
    for(var e=0;
    e<c.getCount();
    e++){
        var f=c.getByIndex(e),g=f.getChildNodeValue("Id");
        if(b==g)a=f.getChildNodeValue("Name")
    }
    (b=Z("greeting_name_display"))&&Wi(b,a)
};
var As=function(a,b){
    if($[C]("$ContactManagerConfig/ShowOldGc")){
        var c=W(a),e={
GreetingId:"0",RingshareId:"0",ForwardingPhones:[],DirectConnect:k
        }
        ;
        if(b&&b.ForwardingPhones)for(var f=0;
        f<b.ForwardingPhones.getCount();
        f++){
            var g=b.ForwardingPhones.getByIndex(f).get();
            e.ForwardingPhones[w](g)
        }
        if(b&&b.GreetingId)e.GreetingId=b.GreetingId;
        if(b&&b.DirectConnect)e.DirectConnect=b.DirectConnect;
        c.getParent().getNode().setChildNode("CallSettings",e)
    }
}
,Bs=function(a,b){
    if(this.el_=Z(a)){
        this.groupIdExpr_=W(b+
        "/CallSettings/GroupId");
        this.settingsTypeExpr_=W(b+"/GcSettingsType");
        this.autoGroupIdExpr_=W(b+"/AutoGroup/ref/id");
        this.setupSelectBox_();
        this.setupListeners_()
    }
};
Bs[y].setupSelectBox_=function(){
    var a=this.groupIdExpr_.getValue(),b=this.settingsTypeExpr_.getValue(),c=this.autoGroupIdExpr_.getValue();
    if(b=="AUTO_GROUP"){
        a=c;
        $[u](this.groupIdExpr_.getSource(),a)
    }
    for(b=0;
    b<this.el_[tc][x];
    b++){
        c=this.el_[tc][b];
        if(a==c[D])ya(c,i)
    }
};
Bs[y].setupListeners_=function(){
    Y(this.el_,"change",this.elementChanged_,k,this);
    Y(this.el_,"keyup",this.elementChanged_,k,this)
};
Bs[y].elementChanged_=function(){
    var a=this.el_[D]||j;
    $[u](this.groupIdExpr_.getSource(),a)
};
var Cs=function(a,b){
    if(this.el_=Z(a)){
        this.dataPath_=b;
        this.greetingIdExpr_=W(b);
        this.greetingsExpr_=W("$UserProfile/GcProfile/Greetings/*");
        this.setSelectedItem_();
        this.setupListeners_()
    }
};
Q=Cs[y];
Q.setSelectedItem_=function(){
    for(var a=this.greetingIdExpr_.getValue(),b=0;
    b<this.el_[tc][x];
    b++){
        var c=this.el_[tc][b];
        if(a==c[D])ya(c,i)
    }
};
Q.setupListeners_=function(){
    Y(this.el_,"change",this.elementChanged_,k,this);
    Y(this.el_,"keyup",this.elementChanged_,k,this);
    var a=Sk();
    a[M]("NEW_GREETING",T(this.addGreeting_,this));
    a[M]("RENAME_GREETING",T(this.renameGreeting_,this));
    a[M]("DELETE_GREETING",T(this.deleteGreeting_,this))
};
Q.renameGreeting_=function(a){
    if(a.id&&a[N]&&!this.inElementChange_){
        this.inEventChange_=i;
        for(var b=this.greetingsExpr_.getNodes(),c=0;
        c<b.getCount();
        c++){
            var e=b.getByIndex(c);
            a.id==e.getChildNodeValue("Id")&&e.setChildNode("Name",a[N])
        }
        for(c=0;
        c<this.el_[tc][x];
        c++){
            b=this.el_[tc][c];
            a.id==b[D]&&Wi(b,a[N])
        }
        this.inEventChange_=k
    }
};
Q.addGreeting_=function(a){
    if(a.id&&a[N]&&!this.inElementChange_){
        this.inEventChange_=i;
        var b=this.greetingsExpr_.getNodes();
        b.add(new wk({
Id:a.id,Name:a[N]
        }
        ,"["+b.getCount()+"]",b));
        b=Ki("option",{
value:a.id
        }
        );
        Wi(b,a[N]);
        this.el_[v](b);
        sa(this.el_,this.el_[tc][x]-1);
        $[u](this.greetingIdExpr_.getSource(),a.id);
        this.inEventChange_=k
    }
};
Q.deleteGreeting_=function(a){
    if(a.id&&a[N]&&!this.inElementChange_){
        this.inEventChange_=i;
        for(var b=this.greetingsExpr_.getNodes(),c=0;
        c<b.getCount();
        c++){
            var e=b.getByIndex(c);
            a.id==e.getChildNodeValue("Id")&&b[Uc]("["+c+"]")
        }
        for(c=0;
        c<this.el_[tc][x];
        c++){
            b=this.el_[tc][c];
            a.id==b[D]&&Ri(b)
        }
        this.inEventChange_=k
    }
};
Q.elementChanged_=function(){
    if(!this.inEventChange_){
        var a=this.el_[D]||j;
        this.inElementChange_=i;
        $[u](this.greetingIdExpr_.getSource(),a);
        this.inElementChange_=k
    }
};
var Ds=function(){
    Sk()[Oc]("GOOGLE_VOICE","event","greeting","action","add")
}
,Fs=function(){
    var a=Es();
    a&&Sk()[Oc]("GOOGLE_VOICE","event","greeting","action","edit","greetingId",a.id,"name",a[N])
}
,Gs=function(){
    var a=Es();
    a&&Sk()[Oc]("GOOGLE_VOICE","event","greeting","action","play","greetingId",a.id)
}
,Es=function(){
    var a=Z("greeting_selector");
    if(a)if(a=a[tc][a.selectedIndex])return{
id:a[D],name:a.innerHTML
    }
    ;
    return j
}
,Vr=function(a){
    if(a.event=="greeting"){
        a=a;
        var b={
rename:"RENAME_GREETING","new":"NEW_GREETING",
            "delete":"DELETE_GREETING"
        }
        ;
        a[Yc]&&a.greetingId&&a[N]&&b[a[Yc]]&&Sk()[Oc](b[a[Yc]],"id",a.greetingId,"name",a[N])
    }
};
ul("goog.focus.GrandCentralBinder",ys,"GrandCentralBinder");
ul("goog.focus.GrandCentralPhoneDisplay",Yj.GrandCentralPhoneDisplay,"GrandCentralPhoneDisplay");
ul("goog.focus.GrandCentralSettingsDisplay",zs,"GrandCentralSettingsDisplay");
ul("goog.focus.GrandCentralSettingsDisplay.setGroupCallSettings",As,"setGroupCallSettings");
ul("goog.focus.AutoGroupSelectBinder",Bs,"AutoGroupSelectBinder");
ul("goog.focus.GreetingsSelectBinder",Cs,"GreetingsSelectBinder");
ul("goog.focus.GrandCentralGreetings.handleAddGreeting",Ds,"handleAddGreeting");
ul("goog.focus.GrandCentralGreetings.handleEditGreeting",Fs,"handleEditGreeting");
ul("goog.focus.GrandCentralGreetings.handlePlayGreeting",Gs,"handlePlayGreeting");
var Ur=function(a,b,c){
    var e={
    }
    ;
    e.SELECT_ON_MOUSE_DOWN=i;
    e.FIXED_HEIGHT=i;
    Ip[J](this,a,b,e);
    this.contactsPath_=c+"/*";
    this.contactsExpr_=W(this.contactsPath_);
    V().addListener(T(this.invalidate,this),c)
};
U(Ur,Ip);
Q=Ur[y];
Q.renderRow=function(a,b){
    var c=a.getChildNodeValue("Name"),e=a.getChildNodeValue("id"),f=a.getChildNodeValue("Count")||0;
    c=se(c);
    xa(b,'<div class="count">'+f+'</div><div class="text" title="'+c+'">'+c+"</div>");
    e==this.selectedGroupId_&&ui(b,"selected")
};
Q.getRowsForRendering_=function(){
    if(!this.manualRowSet_){
        var a=this.rowsExpr_.getNodes();
        pa(this.rows_,0);
        for(var b=a.getCount(),c=0;
        c<b;
        c++){
            var e=a.getByIndex(c);
            this.isCollectContactsGroup_(e)||this.rows_[w](e)
        }
    }
};
Q.selectGroup=function(a){
    this.selectedGroupId_=a;
    this.invalidate()
};
Q.createSectionHeaders_=function(a){
    var b=[];
    if(a[x]!=0){
        var c=1,e=this.isMyContactsGroup_(a[0]);
        if(e){
            b[w](new Lp("",1));
            c++
        }
        for(c=c;
        c<a[x];
        c++)(e=this.isAllContactsGroup_(a[c]))&&b[w](new Lp("",c))
    }
    return b
};
Q.isAllContactsGroup_=function(a){
    return a&&a.getChildNodeValue("id")=="^All"
};
Q.isMyContactsGroup_=function(a){
    return a&&a.getChildNodeValue("id")=="^Mine"
};
Q.isCollectContactsGroup_=function(a){
    return a&&a.getChildNodeValue("id")=="^Collect"
};
var Tr=function(){
};
mf(Tr[y],uh[y]);
var Sr=j;
Tr[y].goTo=function(a){
    a=this.createEvent_(a);
    return this.tryNavigate(a)
};
Tr[y].canGoTo=function(a){
    a=this.createEvent_(a);
    Oa(a,"Navigation.ALLOW");
    return this[F](a)
};
Tr[y].createEvent_=function(a){
    var b;
    if(Od(a)){
        a=new Th(a);
        b={
        }
        ;
        pf(a,function(e,f){
            b[f]=e
        }
        )
    }
    else b=a;
    a=new Ig;
    for(var c in b)a[c]=b[c];
    return a
};
Tr[y].tryNavigate=function(a){
    var b=i;
    if(a.canPrevent!=k){
        Oa(a,"Navigation.ALLOW");
        b=this[F](a)
    }
    if(b){
        Oa(a,"Navigation.GO");
        this[F](a)
    }
    return b
};
